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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With