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 http://python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
$ 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
pip working with it.
$ wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
$ tar xfz distribute-0.6.35.tar.gz
$ cd distribute-0.6.35
$ python2.7 setup.py 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
$ pip install gunicorn supervisor flask
Next post will be about the last 3 Python packages we installed.