Sunday, August 5, 2012

Install Python 2.7 on centos without breaking yum (which depends on 2.4)

Problem Statement:
Here's the deal. I want to be able to run the Datastax Suite on a Red Hat Enterprise Linux Server release 5.5 (Tikanga) vm or a centOS 5.x distro. Datastax has a super nice console for monitoring a Cassandra cluster(s). This web based console requires Python 2.6 or 2.7 (but not 3.x -not supported yet as of 8/5/2012). In addition to the ops console needing a newer python, cqlsh (CQL shell) bundled with Cassandra as of 0.8 requires a modern version of python as well. But the problem is we just can't blindly upgrade to Python 2.7 as there is a hard dependency on Python 2.4 for centOS and RH distros and will cause yum package manager to break. So to keep yum happy, we need versions of python 2.4 and 2.7 side by side
OK, so to do this you need sudo access
Download python and install it in /opt or ~/source. I put mine in ~/source
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xvzf Python-2.7.3.tgz
yum install gcc
cd Python-2.7.3
./configure
make altinstall
The command
make altinstall
is critical because it will prevent replacing the default python directory /usr/bin/python