How To Install Python 2.7 And/Or Python 3.0 on Centos 6

CentOS 6.2 and 6.3 ships with Python 2.6.6. You can manually install Python 2.7 and Python 3.3 but you must be careful to leave the system version alone. Several critical utilities, for example

, depend on Python 2.6.6 and if you replace it bad things will happen.

Below are the steps necessary to install Python 2.7.3 and Python 3.3.0 without touching the system version of Python. The procedure is exactly the same for both versions except for the filenames. People have reported that this also works for CentOS 5.8 but I haven’t tested that. Execute all the commands below as root either by logging in as root or by using


Install development tools

In order to compile Python you must first install the development tools and a few extra libs. The extra libs are not strictly needed to compile Python but without them your new Python interpreter will be quite useless.

Download and install Python

It is critical that you use

below. If you use

you will end up with two different versions of Python in the filesystem both named 

. This can lead to problems that are very hard to diagnose.

Download and install Python 2.7.3

Download and install Python 3.3.0

After running the commands above your newly installed Python interpreter will be available as


. The system version of Python 2.6.6 will continue to be available as



Download and install Distribute

Distribute provides a framework for installing packages from the Python Package Index. Each Python interpreter on your system needs its own install of Distribute.

You can find out what the latest version of Distribute is here. At the time of this edit the current version is 0.6.35. Replace the version number below if there is a newer version available.

Download and install Distribute for Python 2.7

This generates the script 

 that you use to install packages for Python 2.7. It puts your packages in 


Download and install Distribute for Python 3.3

This generates the script 

 that you use to install packages for Python 3.3. It puts your packages in 


What’s next?

Working with multiple versions of Python is difficult and error-prone. I strongly recommend that you install virtualenv and learn how to use it. Virtualenv is a Virtual Python Environment builder that makes it possible to run Python in a sandbox-like environment. Each sandbox can have its own Python version and packages. This is very useful when you work on multiple projects, each with its own dependencies.

Install and use virtualenv for Python 2.7

Install and use virtualenv for Python 3.3



Leave a Reply