I am trying to create a new python 3.7 virtual environment on my local computer running Windows 8. I have python versions 3.6, 3.7, and 3.8 installed. Their exe’s are named python36, python37, and python, respectively. All three are correctly added to PATH because I can enter each interpreter.
Within my new project’s directory I tried to create a virtual environment with python37 -m venv env
. It produced an error: Error: [WinError 2] The system cannot find the file specified
, but it still created the directory. However the Scripts subfolder is empty except for pythonw.exe
.
In this question someone suggests doing python37 -m venv env --without-pip
. When I tried this, the activation/deactivation scripts were created, but the virtual environment is using python 3.8.
It is my understanding that venv will create the virtual environment with what ever python exe you use to call it, so I don’t understand how this can happen. I’ve verified that python37
points to the correct place with where python37
, and can even enter the 3.7 interactive interpreter.
Advertisement
Answer
The problem was that I renamed the python exe’s. I don’t know exactly what goes wrong, but presumably at some point venv
tries to find python.exe
and is thrown off by the name.
Changing them back to python.exe
and differentiating between the versions with their location fixed the problem.
Edit: Check out Eryk’s comments for more details.