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?

- 161
- 4
- 14
-
Have you tried `python -m venv project`? – arshovon May 27 '20 at 07:41
-
Have you checked that python is in your $PATH? – Brian Peacock May 27 '20 at 07:57
-
@arsho where to specify the version when using `python -m venv project` – shrekh May 27 '20 at 08:03
-
In command prompt / terminal write: `python --version` to see what python version is default in your system. – arshovon May 27 '20 at 08:39
-
@arsho 3.7.6 is the default version – shrekh May 27 '20 at 08:42
-
Can you please check if you can see the python 2 version using: `py -2 -V` or `python2 -V`? – arshovon May 27 '20 at 08:49
-
@arsho it opens the interpreter, if that's what you are asking – shrekh May 27 '20 at 08:53
-
No, I want to see if you can access `python2` from command prompt. Please paste the output of `python2 --version` from command prompt. – arshovon May 27 '20 at 08:55
-
`'python2' is not recognized as an internal or external command, operable program or batch file.` But I have `C:\Python27` in my environment variables, which was added by default upon installing – shrekh May 27 '20 at 09:06
-
if `py -2` works, then it is not important, that python2 is in the search path just do `py -2
` instead of `python2 – gelonida May 29 '20 at 00:54`
1 Answers
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,327
- 2
- 23
- 41
-
after running this command, I am getting `can't open file '2.7': [Errno 2] No such file or directory"` – shrekh May 27 '20 at 07:57
-
1I don't have a windows PC at hand. I think I just forgot the `-` before the `2.7` Please retry. Meanwhile I try to find online documentation for the python launcher to be sure this is the right syntax – gelonida May 27 '20 at 08:10
-
-
even though I have virtualenv installed, it is still showing me `No module named venv`, I tried with virtualenv as well but still got the same error – shrekh May 27 '20 at 08:38
-
I am so sorry. Did not even see it before. `venv` 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 – gelonida May 27 '20 at 22:00