Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python3 -m venv: how to specify Python point release/version?

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.

like image 332
mjkrause Avatar asked Feb 14 '19 22:02

mjkrause


People also ask

How do I point to a specific version of Python?

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.

How do I use Python 3.7 in VENV?

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.

What version of Python does VENV use?

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.


1 Answers

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.

like image 174
user2357112 supports Monica Avatar answered Nov 15 '22 07:11

user2357112 supports Monica