Rob*_*son 3 python powershell virtualenv windows-7 pycharm
在PyCharm中,我将终端设置为Windows PowerShell,但是当我尝试在该终端中使用virtualenv时:
Import-Module virtualenvwrapper
Run Code Online (Sandbox Code Playgroud)
(我在启动脚本中有这个命令,但为了简单起见,仅包含命令)
我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
所以我尝试启用脚本执行(就像我在 PyCharm 之外为PowerShell做的那样):
Set-ExecutionPolicy RemoteSigned
Run Code Online (Sandbox Code Playgroud)
但是得到以下错误(我通过以管理员身份运行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
Run Code Online (Sandbox Code Playgroud)
那么我能做些什么来使用PyCharm终端的virtualenv呢?
您获得的权限错误是由Powershell在计算机上没有管理权限引起的.快速解决方案是使用"以管理员身份运行"启动Powershell .从那里,你可以使用Set-ExecutionPolicy
.
Set-ExecutionPolicy RemoteSigned
Run Code Online (Sandbox Code Playgroud)
此外,您可能需要在调用时使用-Scope参数Set-ExecutionPolicy
.有时在子进程中运行Powershell时,使用的执行策略与独立运行PowerShell时的执行策略不同.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3080 次 |
最近记录: |