当我尝试使用命令workon 激活虚拟环境时,虚拟环境不会激活。我使用的是Windows10机器,安装了Virtualenv、VirtualEnvRapper和VirtualEnvRapper win。在
例如,当我在命令shell中输入lsvirtualenv时,我可以看到虚拟环境存在,但我无法激活它。你能帮帮我吗?在
编辑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并将执行策略更改为“remotesigned”,从而使其正常工作。方法如下:
如果当前控制台未提升并且您尝试执行的操作
需要提升的权限,然后可以使用“Run as administrator”启动powershell
选项:
^{pr2}$
可以使用Get-ExecutionPolicycmdlet标识当前执行策略:PS C:\Users\Administrator> get-executionpolicy
为了更改当前的执行策略,Set-ExecutionPolicy cmdlet是
与新的执行策略设置结合使用。例如,更改为
远程签名时,应执行以下命令:PS C:\Users\Administrator> set-executionpolicy remotesignedExecution Policy
Description
Restricted The default policy on Windows PowerShell, this mode disables the execution of script files. Windows PowerShell may only be used by manually issuing commands at the command prompt.
AllSigned Limits execution to scripts which are authenticode signed. When a signed script is executed, PowerShell will prompt for confirmation that the signer of the script can be trusted.
RemoteSigned Requires that any scripts that have been downloaded from a remote location must be signed before they may are permitted to execute.
Unrestricted Allows any script to be executed, regardless of origin or whether it is signed.