簡體   English   中英

Windows 10上安裝了Virtualenvwrapper-win,但無法激活虛擬環境

[英]Virtualenvwrapper-win installed on Windows 10 but can't activate virtual environment

當我嘗試使用命令workon <name>激活虛擬環境時,虛擬環境不會激活。 我正在使用Windows 10計算機並安裝了Virtualenv,VirtualenvWrapper和VirtualenvWrapper-win。

例如,當我在命令外殼中輸入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

執行策略說明受限Windows PowerShell的默認策略,此模式禁用腳本文件的執行。 Windows PowerShell只能通過在命令提示符下手動發出命令來使用。

AllSigned將執行限制為經過Authenticode簽名的腳本。 當執行簽名腳本時,PowerShell將提示您確認腳本的簽名者可以信任。

RemoteSigned要求必須先簽名從遠程位置下載的所有腳本,然后才能允許它們執行。

Unrestricted允許執行任何腳本,無論其來源或是否已簽名。

virtualenv文檔中 ,一種可能的解決方案是放寬系統執行策略,以允許運行本地腳本而無需驗證代碼簽名。

為此,請以管理員身份運行powershell,cd到C:>目錄,然后鍵入以下命令:

PS C:\> Set-ExecutionPolicy RemoteSigned

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM