Virtualwrapper 需要完整的 python3 路径

Virtualwrapper needs the full python3 path

为了避免 sudo pip3 install virtualwrapper 在我的 Ubuntu 上安装了 virtualwrapper 和 apt:

sudo apt-get install virtualenv virtualenvwrapper    

当我只使用以下命令时,我得到了一个 python 2.7 环境:

mkvirtualenv 测试

为了创建 python3 环境,以下突击队不起作用:

test@tester:~$ mkvirtualenv -p python3 test
The executable /home/test/python3 (from --python=/home/test/python3) does not exist

我想要一个 python3 环境,我必须使用以下指令:

mkvirtualenv -p /usr/bin/python3 py3
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/test/.vens/py3/bin/python3
Not overwriting existing python script /home/test/.vens/py3/bin/python (you must use /home/test/.vens/py3/bin/python3)
Installing setuptools, pkg_resources, pip, wheel...done.

为什么使用 -p python3 命令不起作用?

当我对 virtualenv 使用相同的命令时,它起作用了:

test@tester:~$ virtualenv -p python3 test2
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/test/test2/bin/python3
Also creating executable in /home/test/test2/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

根据您遇到的错误,virtualenvwrapper 使用当前工作目录将 -p 选项传递给 virtualenv

你应该这样做:

mkvirtualenv -p `which python3` test