Batista R. Harahap

Python 2.7.5 on CentOS 6.x

For the last few months, I've been coding in Python relentlessly. It's new to me and it just makes sense. The one thing I really like is keeping codes and logic simple. You can comment Python's OOP implementation but then again, everyone got a favourite right?

Most of the servers I handle everyday are CentOS 6.x distros with Python 2.6.x preinstalled by the system. You DON'T wanna upgrade it through yum or any other method, you will break the whole system. So here's to how get Python 2.7.5 working.

$ wget
$ tar xf Python-2.7.5.tar.bz2
$ cd Python-2.7.5
$ ./configure --prefix=/usr/local
$ make -j4
$ make altinstall # DON'T use make install!

Pretty easy right? Python 2.7.5 is now installed at /usr/local/bin and next is to get distribute and pip working with it.

$ wget
$ tar xfz distribute-0.6.35.tar.gz
$ cd distribute-0.6.35
$ python2.7 install
$ easy_install-2.7 pip
$ pip-2.7 install --upgrade pip

Now to make Python 2.7.5 available as your Python environment, virtualenv is what you need. Let's get it on our system.

$ pip-2.7 install virtualenv
$ virtualenv-2.7 /usr/local/python-env --distribute

As it stands, you now have a Python 2.7.5 environment available at /usr/local/python-env instead of the default Python 2.6.x on your system. To activate, do the following.

$ source /usr/local/python-env/bin/activate

Your shell prompt will be prefixed with (python-env) signifying that you are using that particular Python environment. Check your Python version now by doing:

$ which python
$ python --version
Python 2.7.5  

If you're like me who dwells in running a website, you might wanna install gunicorn and supervisor. Try flask while you're at it.

$ pip install gunicorn supervisor flask

Next post will be about the last 3 Python packages we installed.

18 July 2013 by Batista Harahap on 2.7 | centos | python | update | upgrade
comments powered by Disqus