Virtualenvwrapper-win 安装在 Windows 10 但无法激活虚拟环境
Virtualenvwrapper-win installed on Windows 10 but can't activate virtual environment
当我尝试使用命令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 作为管理员并将执行策略更改为“remotesigned”来让它工作。方法见下:
如果当前控制台未提升并且您正在尝试执行的操作
需要提升的权限,然后你可以使用“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
Execution 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.
从 virtualenv docs 开始,一种可能的解决方案是放宽系统执行策略以允许 运行 本地脚本运行而不验证代码签名。
为此,运行 powershell 作为管理员,cd 到您的 C:> 目录并键入以下命令:
PS C:\> Set-ExecutionPolicy RemoteSigned
当我尝试使用命令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 作为管理员并将执行策略更改为“remotesigned”来让它工作。方法见下:
如果当前控制台未提升并且您正在尝试执行的操作
需要提升的权限,然后你可以使用“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
Execution 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.
从 virtualenv docs 开始,一种可能的解决方案是放宽系统执行策略以允许 运行 本地脚本运行而不验证代码签名。
为此,运行 powershell 作为管理员,cd 到您的 C:> 目录并键入以下命令:
PS C:\> Set-ExecutionPolicy RemoteSigned