I have Python 3.5 installed in my windows machine and that is the only version I have on my computer. I want to create a python2.7 virtual environment to try out a certain package. Is it possible to create a virtual environment with python2.7 binaries without installing Python 2.7 in my system?
Asked
Active
Viewed 1,951 times
2 Answers
1
To use a different Python interpreter, that interpreter needs to be on $PATH, which means a binary on your machine.

Zach Valenta
- 1,783
- 1
- 20
- 35
-
That means I need to install python27? – JeanVuda Nov 23 '17 at 15:53
-
yes indeed, although having multiple Python interpreters is not a hassle – Zach Valenta Nov 23 '17 at 17:17
1
You don't need to have your Python interpreter on $PATH, you can tell virtualenv
where to find it. I found this blog post Installing Multiple Python Versions on Windows Using Virtualenv but the TL;DR is:
- Open Command Prompt and enter
pip install virtualenv
. - Download the desired python version (do NOT add to PATH!), and remember the
path\to\new_python.exe
of the newly installed version. - To create a virtualenv, open Command Prompt and enter
virtualenv \path\to\env -p path\to\new_python.exe
. - To install packages:
- Activate virtualenv: open Command Prompt and enter
path\to\env\Scripts\activate.bat
. - Install desired packages with
pip
. - Deactivate with
deactivate
.
- Activate virtualenv: open Command Prompt and enter
Note python3 -m venv \path\to\env
doesn't seem to suppport the -p
parameter, you have to use virtualenv
.

parsley72
- 8,449
- 8
- 65
- 98