Python 2.7 on CentOS 6.2 with Setuptools

First check the python version that is currently install on CentOS 6.2:

python

Before installing the python, please install these packages:

sudo yum install gccgcc-c++.x86_64 compat-gcc-34-c++.x86_64 openssl-devel.x86_64 
zlib*.x86_64 wget make setuptool

Now download the Python 2.7 (In my case, I will download it in tmp directory):

cd /tmp/
wget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2

Switch to the super user (root):

su 

Extract the downloaded Python 2.7 package:

tar -xvjf Python-2.7.tar.bz2

Move to the Python 2.7 directory and configure the package:

cd  Python-2.7
./configure

It’s time to actually build the binary from the source code:

make

Now it’s finally time to install the program:

make install

Edit the user .bash_profile file:

nano ~/.bash_profile

replace PATH=$PATH:$HOME/bin
with PATH=$PATH:$HOME/bin:/opt/python27/bin

Reload the .bash_profile:

source ~/.bash_profile
echo "/opt/python27/lib" > /etc/ld.so.conf.d/python27.conf
ldconfig

Check the Python version now 🙂

python

Now, we will install the setuptool and for this we need to fetch the setuptools from the website:

cd ..
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg

Run the setuptools using this command:

sh setuptools-0.6c11-py2.7.egg

Next, we will install the gevent:

yum install libevent.x86_64 libevent-devel.x86_64

easy_install-2.7greenlet


wget http://pypi.python.org/packages/source/g/gevent/gevent-0.13.0.tar.gz

tar -xvzf gevent-0.13.0.tar.gz

cd gevent-0.13.0

python2.7 setup.py install

Logout from root user and check the python version for user arbab:

exit
python

Hope this will help you!

Please Remember me in your prayers!

4 responses to “Python 2.7 on CentOS 6.2 with Setuptools

  1. Alex August 13, 2012 at 9:15 pm

    Good post. worked for me. Thanks!

  2. Desai August 21, 2012 at 5:25 am

    Spot on. Worked like charm

  3. suneth April 29, 2013 at 5:42 pm

    How to uninstall python 2.7 and go back to python 2.6.6 ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: