Home » Centos/RHEL » How to install python 2.7 on Centos

How to install python 2.7 on Centos

In order to compile Python first we need to install the development tools and some extra libs. Although these extra libraries are not strictly needed to compile Python but without them Python interpreter will be quite useless.
To install python 2.7 on Centos follow the below steps.

yum groupinstall development tools
yum install zlib-devel bzip2-devel openssl-devel xz-libs wget
yum install xz

Download Python Source code and compile

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

# Enter the directory:

cd Python-2.7.6

# Run the configure:

./configure –prefix=/usr/local

# compile and install it:

make
make altinstall

# Check Python version:

[root@linuxpc ~]# python2.7 -V
Python 2.7.6
[root@linuxpc ~]# which python2.7
/usr/local/bin/python2.7

Install setuptools

wget –no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz

# Extract the files:

tar -xvf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2

# Install setuptools using the Python 2.7.6:

python2.7 setup.py install

Installing pip

easy_install-2.7 pip

Install virtualenv

pip2.7 install virtualenv

That’s it.

About

I am founder and webmaster of www.linuxpcfix.com and working as a Sr. Linux Administrator (Expertise on Linux/Unix & Cloud Server) and have been in the industry from last 7 years.

Leave a Reply

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

*
*

Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud