问题
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.
回答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.
来源:https://stackoverflow.com/questions/54700307/python3-m-venv-how-to-specify-python-point-release-version