Skip to content
Justin SilverTECHNOLOGY, TRAVEL & EVERYTHING IN BETWEEN

Linux

Upgrade Python on CentOS

March 21, 2014

The version of python that is distributed with CentOS is the same of that for RHEL, which reads as not cutting edge. Typically this will be version 2.6, so even to run 2.7.6 you will need to build from source, but can still leverage yum to fetch all the dev tools you'll need to build upgraded version of python. Here is how to upgrade python on CentOS for both 2.7 and 3.3. Tweak the version as you wish since newer versions will become available after this is posted.

Python 2.7.6

Downloads Python-2.7.6.tar.xz and builds it.

#!/usr/bin/sh

mkdir -p ~/python2.7
cd ~/python2.7
yum groupinstall -y development
yum install -y bzip2-devel openssl-devel sqlite-devel wget xz-libs zlib-dev 
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
xz -d Python-2.7.6.tar.xz
tar -xvf Python-2.7.6.tar
cd Python-2.7.6
./configure --prefix=/usr/local
make && make install

Python 3.3.3

Same same but different. Python-3.3.3.tar.xz.

#!/usr/bin/sh

mkdir -p ~/python3.3
cd ~/python3.3
yum groupinstall -y development
yum install -y bzip2-devel openssl-devel sqlite-devel wget xz-libs zlib-dev 
wget http://www.python.org/ftp/python/3.3.3/Python-3.3.3.tar.xz
xz -d Python-3.3.3.tar.xz
tar -xvf Python-3.3.3.tar
cd Python-3.3.3 
./configure
make && make install