change default python version with virtualenvwrapper (& virtualenv)

Yunti picture Yunti · Sep 9, 2015 · Viewed 16.1k times · Source

I've recently changed my python setup so that's it's now installed with brew. Previously when using virtualenv and virtualenvwrapper it would default to setting up a new virtualenv using python3 (used for most of my projects). Now unfortunately the default is python2. I can install python3 using:

mkproject -p python3 projectname

however how can i make python3 the default?

Answer

Joe Young picture Joe Young · Sep 9, 2015

To automatically use a custom Python binary instead of the one virtualenv is run with you can also set an environment variable:

$ export VIRTUALENV_PYTHON=/opt/python-3.3/bin/python
$ virtualenv ENV

It’s the same as passing the option to virtualenv directly:

$ virtualenv --python=/opt/python-3.3/bin/python ENV

Source: https://virtualenv.pypa.io/en/latest/reference.html#configuration