Upgrading to Python 2.7 on CentOS 6.5

Hey Folks,

The systems running Tuxlabs are currently running CentOS 6.5 to emulate a production RHEL like setup for an Openstack Cloud. Running an operating system this old has it’s drawbacks such as dependencies. I was recently installing a well know Python framework and ran into compatibility issues. The framework required Python 2.7 and CentOS 6.5 comes with 2.6. The below is a step by step procedure for how to upgrade to Python 2.7 on CentOS 6.5 if  you ever should need it. However, as a reminder run a newer OS when possible and for god sakes if you don’t need Redhat support, run Ubuntu.

Step one, we verify we are indeed running Python 2.6

[tuxninja@diamond ~]$ python --version
Python 2.6.6
[tuxninja@diamond ~]$

Ok then, let’s upgrade Python to 2.7. First let’s update all of our system applications, just in case for version dependencies and it’s good for security etc.

[tuxninja@diamond ~]$ yum -y update

Next, we have to install Develop Tools, it is a required dependency to install Python.

[tuxninja@diamond ~]$ yum groupinstall "Development tools"

Additionally, we will need these…

[tuxninja@diamond ~]$ sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

Now, let’s install Python 2.7

[tuxninja@diamond ~]$ cd /opt
[tuxninja@diamond opt]$ sudo wget --no-check-certificate https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
[tuxninja@diamond opt]$ sudo tar xf Python-2.7.6.tar.xz 
[tuxninja@diamond opt]$ cd Python-2.7.6
[tuxninja@diamond Python-2.7.6]$ sudo ./configure --prefix=/usr/local
[tuxninja@diamond Python-2.7.6]$ sudo make && sudo make altinstall

It is important to use ‘altinstall’ otherwise you will end up with two different versions of Python on your filesystem, both named ‘python’.

You can verify the install like so

[tuxninja@diamond Python-2.7.6]$ ls -la /usr/local/bin/python2.7*
-rwxr-xr-x 1 root root 6214493 Apr 30 15:14 /usr/local/bin/python2.7
-rwxr-xr-x 1 root root    1674 Apr 30 15:14 /usr/local/bin/python2.7-config
[tuxninja@diamond Python-2.7.6]$ /usr/local/bin/python2.7 --version
Python 2.7.6
[tuxninja@diamond Python-2.7.6]$

That’s it ! Enjoy.

Upgrading to Python 2.7 on CentOS 6.5 Read More »