Creating a virtual environment for a different version of python
suggest changeAssuming python and python3 are both installed, it is possible to create a virtual environment for Python 3 even if python3 is not the default Python:
virtualenv -p python3 foo
or
virtualenv --python=python3 foo
or
python3 -m venv foo
python3 -m venv uses that python3 interpreter. The separate pyvenv script was removed in Python 3.8.
You can create a virtual environment based on any working Python on your system. You can check installed interpreters under /usr/bin/ or /usr/local/bin/ on Linux, or in /Library/Frameworks/Python.framework/Versions/X.X/bin/ for the python.org macOS installer, then use that name with the --python or -p flag while creating the virtual environment.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents