How to Install Python 2.7.8 on CentOS/RHEL 6.6

Today, I was trying to install node.js on CentOS 6.6 which required Python 2.7, but there are Python 2.4 install which we cann’t remove as other application’s are already using it. This tutorial will help you to install Python 2.7 without removing older versions.

Step 1: Install GCC and development tools

Firstly make sure that you have gcc package installed on your system. Use following command to install gcc if you don’t have it installed.

yum install gcc
yum groupinstall "Development tools"

You also need a few extra libs installed before compiling Python or else you will run into problems later when trying to install various packages:

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

Step 2: Download Python 2.7

Download Python using below command from python official site

# cd /usr/src
# wget

Step 3: Extract Archive and Compile

Use below set of commands to extract Python source code and compile it on your system using altinstall.

# tar xzf Python-2.7.8.tgz
# cd Python-2.7.8
# ./configure
# make altinstall

make altinstall is used to prevent replacing the default
python binary file /usr/bin/python.

Step 4: Check the Python Version

Check the latest version installed of python using below command

# python2.7 -V
Python 2.7.8




You may also like...

Leave a Reply