virtualenvwrapper side-by-side with python2.7 and python3

142 views Asked by At

I'm starting to do side-by-side work in python2 and python3. (i.e. some projects req python 2 and some req python 3)

How do i use virtualenvwrapper with this requirement?

Do I just install one virtualenvwrapper (either for 2 or for 3) and just set the python binary accordingly at time of virtual env creation? Doesn't seem like that would work.

2

There are 2 answers

0
w-- On

Just doing some initial testing right now and it looks like it works without issue. I'm running the python 3 version of virtualenv wrapper with the python 3 binary, but am able to create venvs for python2.x just fine

e.g.

mkvirtualenv myenv -p /usr/lib/python

My existing venvs also working without issue (so far) with this setup

1
Laughing Horse On

You could just make two separate virtualenvs and specify which python version you'd like on each. Activate them for your python 2 and 3 projects, respectively with:

. ~/.VirtualEnv#/bin/activate

For example:

virtualenv -p python2.7 ~/.VirtualEnv2

virtualenv -p python2.5 ~/.VirtualEnv3