By default centos 6.x comes with Python 2.6 as default, Since python 2.6 is used internally by the os you cant replace it with python 2.7. In this tutorial, I will show you how to install python 2.7 and pip in centos 6.x server along with python 2.6.

Download Python 2.7 Source

cd /usr/src
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz

Compile and Install Python 2.7

tar xzf Python-2.7.10.tgzcd Python-2.7.10
./configure
make altinstall

Create 2.7 Python shortcut in /usr/bin

ln -s /usr/local/bin/python2.7 /usr/bin/python27 

Install pip for Python 2.7

cd /usr/src
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python27 get-pip.py
ln -s /usr/local/bin/pip /usr/bin/pip27 

Check If python 2.7 is installed correctly

python27 -V 

Test pip27 by installing flask package (optional)

pip27 install flask

shyam jos

My name is Shyam Jos, I am a passionate Linux system administrator from Kochi, India. I am a strong advocate of using Linux and Open-Source software.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.