Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change default python version with virtualenvwrapper (& virtualenv)

Tags:

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?

like image 874
Yunti Avatar asked Sep 09 '15 21:09

Yunti


People also ask

How do I specify Python version in virtualenv?

By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag : $ virtualenv -p python3. 2 my_env Running virtualenv with interpreter /usr/local/bin/python3.


1 Answers

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

like image 181
Joe Young Avatar answered Sep 22 '22 15:09

Joe Young