3

PyCharm では、端末を Windows PowerShell に設定しましたが、その端末で virtualenv を使用しようとすると、次のようになります。

Import-Module virtualenvwrapper

(このコマンドは起動スクリプトに含まれていますが、簡単にするためにコマンドのみを含めました)

次のエラーが表示されます。

Import-Module : File C:\Users\Sean\Documents\WindowsPowerShell\Modules\virtualenvwrapper\support.psm1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:14
+ Import-Module <<<<  virtualenvwrapper
    + CategoryInfo          : NotSpecified: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.ImportModuleCommand

そこで、スクリプトの実行を有効にしようとしました ( PyCharm以外の PowerShell で行ったように):

Set-ExecutionPolicy RemoteSigned

しかし、次のエラーが発生します (PowerShell を管理者として実行することで、PyCharm の外部でこのエラーを回避しました):

Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.
At line:1 char:20
+ Set-ExecutionPolicy <<<<  RemoteSigned
    + CategoryInfo          : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

では、PyCharm ターミナルから virtualenv を使用できるようにするにはどうすればよいでしょうか?

  • ウィンドウズ7
  • パイソン 2.7
  • PyCharm コミュニティ エディション 3.0
4

2 に答える 2

6

The permissions error you are getting is caused by Powershell not having administrative rights on the machine. The quick solution is to start up Powershell using Run as Administrator. From there, you can use Set-ExecutionPolicy.

Set-ExecutionPolicy RemoteSigned

In addition, you might need to use the -Scope parameter when calling Set-ExecutionPolicy. Sometimes when running Powershell in a child process, the execution policy used is different than when running powershell independently.

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
于 2013-09-29T02:43:02.527 に答える