Skip to main content
 首页 » 编程设计

python之无法让 virtualenvwrapper 工作

2025年05月04日28lori

运行成功

pip install virtualenvwrapper 

但我无法运行接下来的两个命令。

PS C:> export WORKON_HOME=~/Envs 

错误是:

The term 'export' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the spelling of the name, or if a path was included, verify that 
the path is correct and try again. 
At line:1 char:7 
+ export <<<<  WORKON_HOME=~/Envs 
    + CategoryInfo          : ObjectNotFound: (export:String) [], CommandNotFoundException 
    + FullyQualifiedErrorId : CommandNotFoundException
PS C:> source /usr/local/bin/virtualenvwrapper.sh 

错误是:

The term 'source' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the spelling of the name, or if a path was included, verify that 
the path is correct and try again. 
At line:1 char:7 
+ source <<<<  /usr/local/bin/virtualenvwrapper.sh 
    + CategoryInfo          : ObjectNotFound: (source:String) [], CommandNotFoundException 
    + FullyQualifiedErrorId : CommandNotFoundException

我想我的问题是我不知道我在用 PowerShell 做什么。最初,我无法让 pip 或 virtualenv 工作,直到我输入:

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\Scripts", "User") 

一旦我这样做了,我就能够从任何位置毫无问题地运行 pip 或 virtualenv。我想不通的是如何成功运行 virtualenvwrapper 页面上指定的最后两行。

请您参考如下方法:

virtualenvwrapper 适用于类 Unix 操作系统,例如Linux 和 OS X。看看 virtualenvwrapper-powershell .这是officially recommended by virtualenvwrapper .

有 virtualenvwrapper-win适用于 Windows 命令提示符。也是recommended by virtualenvwrapper .

还有instructions for MSYS .