Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtualenv with python2 and python3 via Homebrew

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

like image 740
wonbyte Avatar asked Sep 24 '12 13:09

wonbyte


People also ask

Can I install different versions of Python into virtual environments?

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.

Does Python 2.7 support virtualenv?

Python and OS Compatibility. virtualenv works with the following Python interpreter implementations: CPython versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10.


1 Answers

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.

like image 59
Pierre GM Avatar answered Oct 18 '22 10:10

Pierre GM