简体   繁体   中英

How to choose Python version when making a new virtual environment with virtualenvwrapper?

It seems like the current global Python version provided by pyenv-win is automatically being employed, but there seems to be no option or parameter in the commmand mkvirtualenv of virtualenvwrapper to specify a Python version.

Eg my current global pyenv Python version is this:

PS C:\WINDOWS\system32> pyenv global
3.9.0a4

Last time, I created a virtual environment via PowerShell using the virtualenvwrapper-powershell in particular with this command:

MkVirtualEnv -Name MyEnv -Python ThePythonDistDir

As you can see, the ThePythonDistDir needs to be passed by the user and thus refers to an already existing Python -version installed in some directory; in my case via pyenv-win .

So, is there a way to choose directly with virtualenvwrapper a new Python version, which would then be downloaded and installed automatically?

Thanks to all the info @phd has given me in the comments, the alternatives are:

  1. Option parameter to the mkvirtualenv - function hidden in virtualenv options , eg: mkvirtualenv --python C:\Python27\python.exe

  2. Globally activate a Python version of desired, eg via pyenv global 3.9.0 , before running the command mkvirtualenv to create the new venv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM