0

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.

E.g. 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?

Andreas L.
  • 3,239
  • 5
  • 26
  • 65
  • No `virtualenv/wrapper` cannot downloaded Python. Some other tool should do that before running `virtualenv`/`mkvirtualenv`. `pyenv-win` is such a tool. – phd Apr 21 '21 at 17:48
  • Alright, and in order to choose _which_ `Python` version exactly, one has to set the _global_ `Python` before creating a new venv with `virtualenvwrapper`, because it will always automatically adopt this very `Python` version? – Andreas L. Apr 22 '21 at 07:14
  • This is just one solution. Naming the version explicitly every time is another. – phd Apr 22 '21 at 08:08
  • Where/how/at which point of the procedure do I "name" the version explicitely? There is no option or parameter associated with the command `mkvirtualenv` where I could do that, could you be more precise, please? – Andreas L. Apr 22 '21 at 08:10
  • 1
    `mkvirtualenv --python C:\Python27\python.exe` – phd Apr 22 '21 at 08:11
  • Thanks, it's weird though that they don't mention this capability in the docs: https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html#mkvirtualenv – Andreas L. Apr 22 '21 at 08:15
  • It's hidden in `[virtualenv options]`: https://virtualenv.pypa.io/en/latest/cli_interface.html#section-discovery – phd Apr 22 '21 at 08:16

1 Answers1

0

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, e.g.: mkvirtualenv --python C:\Python27\python.exe

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

Andreas L.
  • 3,239
  • 5
  • 26
  • 65