Virtualenvwrapper-win安装在Windows 10上,但无法激活虚拟环境

时间:2015-09-03 00:55:14

标签: python virtualenv windows-10 virtualenvwrapper virtualenv-commands

当我尝试使用命令workon <name>激活虚拟环境时,虚拟环境不会激活。我正在使用Windows 10机器并安装了Virtualenv,VirtualenvWrapper和VirtualenvWrapper-win。

例如,当我在命令shell中输入lsvirtualenv时,我可以看到<name>虚拟环境存在,但我无法激活它。你能帮我吗?

编辑#1:

当我尝试直接激活文件时,我从终端收到以下错误:

PS C:\users\stefan\envs\rango\scripts> .\activate .\activate : File C:\users\stefan\envs\rango\scripts\activate.ps1 cannot be loaded. The contents of file C:\users\stefan\envs\rango\scripts\activate.ps1 might have been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital signature. The script cannot run on the specified system. For more information, run Get-Help about_Signing.. At line:1 char:1 + .\activate + ~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : Unauth – 

编辑2 -

我能够通过以管理员身份运行powershell并将执行策略更改为&#34; remotesigned &#34;来使其工作。请参阅下面的方法:

如果当前控制台未升级并且您正在尝试执行此操作 需要提升权限,然后您可以使用&#34; Run as administrator&#34; 选项:

PS> Start-Process powershell -Verb runAs

可以使用Get-ExecutionPolicy cmdlet:

标识当前的执行策略
PS C:\Users\Administrator> get-executionpolicy

为了更改当前的执行策略,Set-ExecutionPolicy cmdlet是 与新的执行策略设置一起使用。例如,要更改为 RemoteSigned,应执行以下命令:

PS C:\Users\Administrator> set-executionpolicy remotesigned
  

执行政策   描述   受限制Windows PowerShell上的默认策略,此模式禁用脚本文件的执行。只能通过在命令提示符下手动发出命令来使用Windows PowerShell。

     

AllSigned限制执行到authenticode签名的脚本。执行签名脚本时,PowerShell将提示确认脚本的签名者是否可信任。

     

RemoteSigned要求必须先签署从远程位置下载的所有脚本,然后才能执行这些脚本。

     

Unrestricted允许执行任何脚本,无论其来源或是否已签名。

1 个答案:

答案 0 :(得分:0)

virtualenv docs开始,一种可能的解决方案是放宽系统执行策略,以允许运行本地脚本而无需验证代码签名。

要做到这一点,请以管理员身份运行powershell,cd到您的C:&gt;目录并键入以下命令:

PS C:\> Set-ExecutionPolicy RemoteSigned