当我试图使用命令workon <name>激活虚拟环境时,虚拟环境不会激活。我使用的是Windows 10机器,并安装了Virtualenv、VirtualenvWrapper和VirtualenvWrapper-win。
例如,当我将lsvirtualenv输入命令shell时,我可以看到<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并将执行策略更改为“远程签名”,我能够让它工作。方法见下文:
如果当前控制台未被提升,并且要执行的操作需要提升权限,则可以使用"Run as administrator“选项启动powershell:
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上的默认策略,此模式禁用脚本文件的执行。Windows PowerShell只能通过在命令提示符下手动发出命令来使用。 AllSigned将执行限制在已签名的签名脚本上。执行签名脚本时,PowerShell将提示确认脚本的签名者是可信的。 RemoteSigned要求从远程位置下载的任何脚本必须在允许执行之前进行签名。 不受限制地允许执行任何脚本,而不管它来自何处或是否被签名。
发布于 2016-08-31 07:58:16
从虚拟文档中,一种可能的解决方案是放松系统执行策略,允许运行本地脚本而不验证代码签名。
为此,请以管理员身份运行powershell,cd到您的C:>目录,并键入以下命令:
PS C:\> Set-ExecutionPolicy RemoteSignedhttps://stackoverflow.com/questions/32365380
复制相似问题