Skip to content Skip to sidebar Skip to footer

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 Pyt

Solution 1:

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.

Solution 2:

I was able to avoid error mentioned in the comments by using the option --without-pip. Then after activating the venv, I installed pip manually with the get-pip.py script.

Solution 3:

I thought to add to this answer when one is using pyenv. In my workflow I use pyenv to have multiple python versions but not to manage virtualenvs. I rather have my python virtual environment in the project's root. With pyenv one can install multiple python versions by running pyenv install 3.8.10 and after that pyenv install 3.9.0. When you run pyenv versions you should get something similar to this

  system
* 3.8.10 (set by /Users/<user>/.pyenv/version)
  3.8.10/envs/python-test.venv
  3.9.0

When working on a project and choosing what python version should be used in that project you can do the following.

$ mkdir my_project && cd my_project
$ pyenv global <version>
$ python --version // should be the version you set as global
$ python -m venv .venv
$ source .venv/bin/activate

Post a Comment for "Python3 -m Venv: How To Specify Python Point Release/version?"