Search code examples
pythonvirtualenvwrapper

Virtualwrapper needs the full python3 path


In order to avoid to sudo pip3 install virtualwrapper have installed virtualwrapper on my Ubuntu with apt:

sudo apt-get install virtualenv virtualenvwrapper    

When I only use the following command I do get a python 2.7 environment:

mkvirtualenv test

In order to make a python3 environment the following commando do not work:

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

I order to have a python3 environement I have to use the following commando:

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.

Why does it not work to use the -p python3 command?

When I use the same command with virtualenv, it works:

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.

Solution

  • According to the error you got, virtualenvwrapper passes the -p option to virtualenv using the current working directory.

    You should do:

    mkvirtualenv -p `which python3` test