Problems with venv module when there are multiple versions of python in the path

Viewed 75

I'm in Windows 10 and I have python 3.7, 3.8, and 3.9 in the Path

The procedure that I used to install and leave the multiple versions on the path was the following: First I installed python 3.7 in C:\Users\MyExampleUser\AppData\Local\Programs\Python\Python37\, then I copied the python.exe into python37.exe. I did exactly the same for the other versions,

This allows me to call a desired python version by adding the 3x suffix. The default python version is 3.7 (i.e when I call python without suffix). Now,
When I want to create a virtual environment using venv, doing

python -m venv .venv

It does not cause me any problem (i.e virtualenv with python 3.7 which is the default), but If I add any suffix (including 3.7)

python3x -m venv .venv

I get this error

Error: [WinError 2] The system cannot find the specified file

If I add the full path to the python folder, for example,

C:\Users\MyExampleUser\AppData\Local\Programs\Python\Python39\python.exe -m venv .venv

I have no problems.

I suspect that the venv script is calling the executable somewhere as python.exe, which goes against the suffix I added to differentiate the multiple versions of python, and I imagine many other modules do the same. My question is how to deal well with multiple versions without incurring these errors.

0 Answers
Related