I want to create a virtual environment with python version 2.7 on windows, however, after installing virtualenv and running python 2.7 -m venv project
I am receiving an error RuntimeError: failed to find interpreter for Builtin discover of python_spec='2.7'
I have downloaded the 2.7 version of python as well, what am I missing?
1 Answer
venv is a package that was only introduced from python 3.3 and above.
( https://docs.python.org/3/library/venv.html )
I never used it.
You might use virtualenv, that exists also for python 2.7. but must be installed with following command (but you did this probably already)
py -2.7 -m pip install virtualenv
You then type
py -2.7 -m virtualenv project_dir
if none of above works, then please type
py -2.7 -m pip freeze and post the output.
You can also type
py -2.7 -c "import sys ; print(sys.executable, sys.version_info)"
To see what python 2.7 version you have exactly installed.
The difference between py.exe and python.exe:
On windows py.exe is the python launcher, that tries to keep track of all installed python versions and of potentially activated virtualenvs and launches the one you want.
python will try to find the python executable in the search path.
and it would yield the first python in the path.
py is the windows python launcher which will locate the python executables with help of environment variables and the registry and which allows with the -version (e.g. -2.7) switch to select which version of python you want to call.
( Documentation for the python launcher on windows: https://docs.python.org/3/using/windows.html#from-the-command-line )
5 Comments
can't open file '2.7': [Errno 2] No such file or directory"- before the 2.7 Please retry. Meanwhile I try to find online documentation for the python launcher to be sure this is the right syntaxNo module named venv, I tried with virtualenv as well but still got the same errorvenv and virtualenv are two distinct modules. venv was only introduced from python 3.3 and above. For python 2.7. you can use virtualenv . Perhaps you can use venv from your python 3 version to create a virtualenv for python 2.7, but I don't think so. First quick searches don't indicate this
python -m venv project?python -m venv projectpython --versionto see what python version is default in your system.