Last Updated: February 25, 2016
·
463
· louy2

Create Python 2.7 virtualenv with Python 3.4 in PATH on Windows

Installing virtualenv under Python 3.4 and point it to Python 2.7 resulted in error. After some research it turns out Python 3.4 has venv. But I want a Python 2.7 environment.

The solution is totally unrelated to Python 3.4.

Before everything, install Python 2.7.

First, install pip under Python 2.7 by get-pip.py. With py launcher that is:

py -2 get-pip.py

Then add the resulting executables to PATH. Usually it is:

<install path>/Python27/Scripts

Now that pip2 is ready, use it to install virtualenv.

pip2 install virtualenv

The virtualenv is now really and defaults to Python 2.7. It is now available to create environments.

virtualenv <path of environment>

Btw, re-installing pip in an attempt to obtain pip2 resulted in error as well.