当我尝试从 GIT bash mingw32 激活我的 virtualenv 时,我没有得到预期的响应。
注意: py
是我的 Google Drive 文件夹中 Python 项目的文件夹。 hy
是我运行时创建的 virtualenv 文件夹 virtualenv --distribute hy
。
s3z@s3z ~/Google Drive/py/hy
$ Scripts/activate
所以你看,在 s3z@s3z ~/Google Drive/py/hy
之前没有出现预期的(hy)
s3z@s3z ~/Google Drive/py/hy
$ Scripts/activate.bat
Scripts/activate.bat: line 1: @echo: command not found
Scripts/activate.bat: line 4: syntax error near unexpected token `('
Scripts/activate.bat: line 4: `if not defined PROMPT ('
当以实际文件名 activate.bat
为目标时,我收到错误消息。然后我尝试停用看看会发生什么,因为我认为 virtualenv 可能被激活但被隐藏了。
s3z@s3z ~/Google Drive/py/hy
$ Scripts/deactivate.bat
Scripts/deactivate.bat: line 1: @echo: command not found
Scripts/deactivate.bat: line 3: syntax error near unexpected token `('
Scripts/deactivate.bat: line 3: `if defined _OLD_VIRTUAL_PROMPT ('
s3z@s3z ~/Google Drive/py/hy
$ Scripts/deactivate
sh.exe": Scripts/deactivate: No such file or directory
有任何想法吗?
原文由 user883807 发布,翻译遵循 CC BY-SA 4.0 许可协议
执行
Scripts/activate
在 shell 的新实例中运行脚本,该实例在脚本执行后被销毁。要在当前 shell 中运行脚本,请使用. Scripts/activate
或source Scripts/activate
。Scripts/activate.bat
在这里不起作用,因为它是用 Batch、Windowscmd.exe
语言编写的,而不是 Bash。