Create a virtualenv with both python2 and python3

Sorry, virtualenv is designed to support single interpreter version.

If you need to use several python versions on the same codebase please create separate virtual environments.


virtualenv does not support multiple interpreter versions . My suggestion is to use different environment for each of the versions :

virtualenv -p /usr/bin/python3.3 py3env
virtualenv -p /usr/bin/python py2env

virtualenv help you to isolate environments.

It can't support multiple python version in the same time. You can try pyenv and pyenv-virtualenv. It support you change folder to another python version and work environment. It switch version very easily.

If you can't install pyenv and work on Mac. anyenv can help you to install pyenv.

Example:

$ pyenv install 3.4.1
$ pyenv install 2.7.6
$ pyenv virtualenv 3.4.1 mypy3
$ pyenv virtualenv 2.7.6 mypy2
$ pyenv versions
  * system
    3.4.1
    2.7.6
    mypy3

$ cd /work/
$ pyenv local mypy3      # Use Py3 now
$ pyenv local mypy2      # Use Py2 now