How to use multiple Python versions on the same System?

I am trying to install Keryx which requires python < 2.7

I want to be able to use this software and yet not uninstall the newer version of python from my system and mess up any other programs that might be using it.

How can I install the above in my current setup?

A similar question exists here but does not have a valid answer -

How can I downgrade Python or use many versions?


Solution 1:

You can easily install Python 2.6 from the archives:

sudo apt-get install python2.6

Note 1: The default Python version (/usr/bin/python) will remain Python 2.7. To use version 2.6 you will need to use /usr/bin/python2.6 explicitly.

Note 2: Generally speaking, it is safe to install more than a version of the same software as long as you use packages provided by your distribution. If you want to install a version of a software not provided by the distribution, be sure to install it to /usr/local, or better use some isolation mechanisms (e.g. virtual environments/machines).