9

我正在尝试virtualenv[wrapper]通过 Cygwin 在我的 Windows 机器上工作。安装成功,连同easy_install,基于这些方向: http: //www.doughellmann.com/docs/virtualenvwrapper/

当我使用mkvirtualenv [name_of_vir_env]. 我得到以下输出:

$ mkvirtualenv testenv
New python executable in testenv\Scripts\python.exe
Installing setuptools.................done.
bash: D:\.virtualenvs/testenv/bin/postactivate: No such file or directory
chmod: getting attributes of `D:\\.virtualenvs/testenv/bin/postactivate': No such file or directory
bash: D:\.virtualenvs/testenv/bin/predeactivate: No such file or directory
chmod: getting attributes of `D:\\.virtualenvs/testenv/bin/predeactivate': No such file or directory
bash: D:\.virtualenvs/testenv/bin/postdeactivate: No such file or directory
chmod: getting attributes of `D:\\.virtualenvs/testenv/bin/postdeactivate': No such file or directory
ERROR: Environment 'D:\.virtualenvs/testenv' does not contain an activate script.

testenv目录内部,没有bin子目录,只有Liband ScriptsScriptscontainsactivate.bat应该被用来激活这个特定的环境,但是如果我尝试运行它,bash我会得到一个错误:

$ ./activate.bat
./activate.bat: line 1: @echo: command not found
./activate.bat: line 4: syntax error near unexpected token `('
./activate.bat: line 4: `if not defined PROMPT ('

我可以退出bash并调用activate.bat,这将更改为所需的环境。但是不在bash我不能使用该workon命令或任何其他命令virtualenvwrapper_bashrc

我怎样才能让两者一起工作,也就是说,留在里面,bash这样我就可以使用里面的命令了virtualenvwrapper_bashrc

4

4 回答 4

3

我没有使用 virtualenvwrapper 的经验,但确实经常使用 virtualenv。我不认为 activate.bat 打算在 cygwin 下运行,它在常规 Windows shell 中运行时可以工作。我认为如果您使用的是 cygwin,您可能想要使用更像 bin/activate(类 unix 操作系统的版本)之类的东西。

bash 中的 cygwin 环境可能与 activate.bat 期望运行的标准环境大不相同,因此找到一个可以与 bash 一起使用的激活脚本(也许从 unix 版本中找到一个副本)可能会让你到达可以运行的地方你在 bash 中的 virtualenv。

于 2011-01-29T02:49:21.540 回答
1

这篇文章看起来很有希望 http://atbrox.com/2009/09/21/how-to-get-pipvirtualenvfabric-working-on-cygwin/

——昆汀

于 2010-12-01T05:02:47.223 回答
1

这为我做到了:

https://bitbucket.org/cliffxuan/virtualenvwrapper-for-cygwin-windows-python

vanillavirtualenvwrapper似乎不支持 Cygwin 环境。

但是需要注意的是,Scriptsvirtualenv 目录下的可执行脚本只有在您将它们显式传递给python命令并且不使用~或 Cygwin 隐式转换路径开头的任何其他内容时才可执行/cygdriv/c/...- 本机 Windows Python 无法看到这些路径。

于 2012-09-15T18:28:37.267 回答
0

我不知道 virtualenv,但我看到了 cygwin 的经典混合路径语法问题:

你的字符串是:

D:\.virtualenvs/testenv/bin/predeactivate

但 Cygwin 将反斜杠解释为“。”的转义。性格,产生:

D:.virtualenvs/testenv/bin/postactivate

这在您引用的错误文本中,显然是格式错误的路径。检查您的实际环境变量 - 它可能采用 DOS/Windows 路径语法,而内部部分采用 cygwin/unix 语法。

如果是这样,请尝试使用 os.path.join 将这两个部分拼接在一起,看看是否能得到一致的语法。

于 2010-12-16T00:11:00.803 回答