Installing Python 2.7 on CentOS 5

CentOS comes with python 2.4, which should not be replaced by other versions of Python. To install a different version of Python, I followed the instruction here:

Note that you may need root or sodu to use the instruction in the following.

http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/

There are some tips about virtualevn and virtualevnwrapper, which is not described in detail in the aforementioned link. Please refer to the following links.

http://stackoverflow.com/questions/5764494/how-to-use-python-virtualenv

http://stackoverflow.com/questions/13855463/bash-mkvirtualenv-command-not-found

http://www.doughellmann.com/articles/pythonmagazine/completely-different/2008-05-virtualenvwrapper/index.html

Actually, I install Python 2.7 to use matplotlib. When I was trying to install matplotlib, I found there were some libs missing. Here is a link about the libs needed for matplotlib.

http://askubuntu.com/questions/38312/cant-compile-matplotlib-on-ubuntu-11-04-ft2build-h-no-such-file-or-directory

Somehow, I managed to set up the virtualenv for my python 2.7. I install it in /usr/local/bin, and my ~/.bashrc looks like this:


# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

I set up a virtual environment called p2.7. To use it, simply used command

workon p2.7
Advertisements

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