Image for post: Installing both Python 2 and 3 in the same computer

Installing both Python 2 and 3 in the same computer

I was wondering if I can have both Python 2 and 3 on Windows. To solve this problem I have followed some simple steps.

Windows

  • Install Python 2
  • Add c:\Python2 path on the path of your environment variables
  • Rename python.exe as python2.exe
  • Install Python 3
  • Add c:\Python3 path on the path of your environment variables
  • Rename python.exe as python3.exe

Done! Now if you want to use Python 2 from your CLI, you will type python2 <filename> or python3 <filename> if you want to use Python 3.

As you can see you don't need to install any additional software.

Linux

Here you follow the same principle: Install both version you need on different directory and let your system know about the different path and the different versions of Python. Here is a solution.

I hope it will be useful. Enjoy programming with Python!