7

I have installed python2 and python3 with Homebrew. I would like to use virtualenv but I am not sure if I need to install it for both python2/python3. I am also wondering if I use virtualenvwrapper can I just set the VIRTUALENVWRAPPER_PYTHON to be either python2 or python3 depending on my needs?

Any help is greatly appreciated.

Thanks, Greg

wonbyte
  • 971
  • 2
  • 11
  • 23

1 Answers1

15

According to this SO question, you could use a single virtualenv for both version, just use the -p path/to/python/version or --python=path/to/version flag to specify which version to use for the creation of the virtual environment. Note that you can use the same flag with mkvirtualenv.

This post recommends to just use the system Python (2.7 in your case) to install virtualenv itself.

Community
  • 1
  • 1
Pierre GM
  • 19,809
  • 3
  • 56
  • 67
  • Do you mean that one can use the same virtualenv program? What I understand from the mentioned SO question, is that you need a separate virtual environment for the two Python versions. – Seppo Enarvi May 13 '13 at 17:20
  • 2
    You can have python2.x *and* python3.x in the *same* virtual environment. For example, with `virtualenvwrapper`, you can do `mkvirtualenv test; mkvirtualenv test -p /usr/local/bin/python3`; in that case, the env's `python` will point to the latest installed (python3.), but you'll still have links to both python2.x and python3.x. – Pierre GM May 13 '13 at 19:12
  • 1
    This worked for me, although it was the other way around: python was left pointing to the first installed version, and I have to call python3 explicitly. – Seppo Enarvi May 15 '13 at 12:09