Thursday, June 13, 2013

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!

No comments:

Post a Comment