To create a virtual environment using virtualenv
you can specify the Python release and point version like so:
virtualenv --python=python3.6 .venv
How can I achieve this using Python3's venv
module (as in python3 -m venv .newvenv
)? According to the documentation using venv
is the recommended way to create virtual environments but I didn't see how I can choose a virtual environement with a specific Python version.
As a standard, it is recommended to use the python3 command or python3. 7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed. You can also use commands like py -3.7 to select a particular version, or py --list to see which versions can be used.
Show activity on this post. You will see something like this: Running virtualenv with interpreter C:\Python37\python.exe Using base prefix 'C:\Python37' New python executable in C:\Users\XXXX\Documents\GitHub\MyProject\venv\Scripts\python.exe Installing setuptools, pip, wheel... done.
Creating a Python Virtual Environment virtualenv supports older Python versions and needs to be installed using the pip command. In contrast, venv is only used with Python 3.3 or higher and is included in the Python standard library, requiring no installation.
Run venv
with whatever Python installation you want to use for the new virtual environment. For example, if you would run your Python 3.6 installation with python3.6
, then
python3.6 -m venv whatever
would be how you create a Python 3.6 virtual environment.
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