Install Python 2.7 on CentOS 6

CentOS 6 comes with python 2.6, to install python 2.7, first install gcc and dependencies yum

yum -y install gcc
yum -y install openssl-devel libzip-devel zlib-devel libcurl-devel libcurl

Download latest Python 2.7 from

https://www.python.org/downloads/

For Python 2.7.2 (latest at the time of writing this post).

cd /usr/local/src
wget https://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar xvf Python-2.7.2.tgz 
cd Python-2.7.2
./configure
make altinstall

We use “make altinstall” so python will be installed as python2.7. If you do “make install”, it replace system python binary and break CentOS.

Install pip

wget https://bootstrap.pypa.io/get-pip.py
python2.7 get-pip.py

Comments

Leave a Reply

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