Fangyijie Wang

How to install python2 & 3 together in Windows

This post will introduce how to install Python 2 and Python 3 together in Windows 7 on the same PC.

Download Python2 & 3

Nevigate to Python official website and download latest Python2 installer and Python3 installer. Please choose the correct version for your Windows 7 system. For example, my Windows 7 is 64 bit, so I would choose Windows x86-64 MSI installer version for Python2 and Windows x86-64 executable installer for Python3.

Install Python2 & 3

Run the two installers which you just downloaded. When you install Python3, there is an option you could choose to add Python3 to environment variables PATH, or please go to next step to add Python2 & 3 to environment variables.

Add Python to environment variables

Right Click on My Computer and go to Properties. Go to Advanced System Settings. Click on Environment Variables and edit PATH and add the path to your Python 3 and Python 2 installation directories.

Please see below PATH variable on my computer.


(IMPORTANT) Copy python.exe to python3.exe or python2.exe

Now if you go to Windows command line and type below command

pyhon --version

the output should be like this

only one python version shown up

There is only one Pyhton version shown up. If the Python version is shown as 2.7.13, go to Python 3 installation directory (mine is C:\python3). And copy python.exe to the same directory. Rename the copied exe file as python3.exe. Do the similar for Python2, but rename the copied exe file as python2.exe in Python 2 installation directory.

Then go to Windows command line again, try to type below two commands and check their outputs.

python2 --version
python3 --version

Hopefully you could get the same results as below

two python versions shown up

As you can see Python 2 and 3 are both available now on the same computer. To use them, run python2 to call Python 2 or python3 to call Python 3.