python - 如何让 virtualenvwrapper 和 cygwin 合作?

标签 python cygwin virtualenv

我正在尝试通过 Cygwin 让 virtualenv[wrapper] 在我的 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 子目录,只有 LibScriptsScripts 包含 activate.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 中的命令?

最佳答案

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

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

关于python - 如何让 virtualenvwrapper 和 cygwin 合作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2173963/

相关文章:

C++ 编译错误 - undefined reference

python - 在 python 中将 ISO8601 格式转换为秒,无需使用任何外部库

python - 单个 get_queryset() 中的多个模型用于填充模板中的数据

bash - 如何使用 cygwin bash 日期实用程序找到当月的第一个星期一?

由 cygwin 创建的 Windows 快捷方式 (.lnk) 的 Java 解析器

python - Python3 的 venv 与 virtualenv 有何不同?

python - 使用 Python 虚拟环境时,include 和 libs 在哪里?

python - 如何在 pycharm 中设置 virtualenv 和依赖项?

python - 如何使用 python 脚本以编程方式安装 PIL

python - 在 Kivy 中构建一个简单的进度条或加载动画?