44 python git bash virtualenv git-bash
当我尝试从GIT bash mingw32激活我的virtualenv时,我没有得到预期的响应.
注意:py
是我的Google云端硬盘文件夹中的Python项目文件夹.hy
是我跑的时候制作的virtualenv文件夹virtualenv --distribute hy
.
s3z@s3z ~/Google Drive/py/hy
$ Scripts/activate
Run Code Online (Sandbox Code Playgroud)
所以你看,之前没有预期的(hy) s3z@s3z ~/Google Drive/py/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 ('
Run Code Online (Sandbox Code Playgroud)
当定位实际文件名时,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
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Pie*_*don 87
做好Scripts/activate
运行脚本的外壳,这是脚本执行后销毁的新实例.要在当前shell中运行脚本,请使用. Scripts/activate
或source Scripts/activate
.
Scripts/activate.bat
在这里不起作用,因为它是用Batch,Windows cmd.exe
语言编写的,而不是Bash.
Nat*_*ler 16
要在Windows 10中访问Python,您需要在创建虚拟环境时添加.exe。
$ python.exe -m venv Scripts
Run Code Online (Sandbox Code Playgroud)
然后您可以进入为虚拟环境创建的脚本文件夹。
$ cd Scripts/
Run Code Online (Sandbox Code Playgroud)
现在您必须调用它来激活虚拟环境。
$ source ./Scripts/activate
Run Code Online (Sandbox Code Playgroud)
完成后,您只需停用虚拟环境即可。
$ deactivate
Run Code Online (Sandbox Code Playgroud)
在 Windows10 上,您可以进入放置 Scripts 文件夹的 virtualenv 目录,然后输入以下命令
source ./Scripts/activate
Run Code Online (Sandbox Code Playgroud)
请注意 .(dot) 没有这个,当我像上面提到的那样使用它时它会给我错误,然后由 Pierre 提供的解决方案为我工作。