Install Python 2.6 on CentOS 5

Anthony Zhan| 2013-07-20 Web Hosting, Tutorials Comments( 0 )

CentOS 5 is the most common Python hosting environment in the market, but the default version of python it is 2.4 now. As some projects request the python version to be greater than V2.5, in this article, you will see how to install python 2.6 by compiling source code step by step. 1. Download python source from python.org and Uncompress it.

$ wget http://www.python.org/ftp/python/2.6.7/Python-2.6.7.tgz
$ tar xzvf Python-2.6.7.tgz

2. Build & Install. In the source code folder:

$ ./configure --prefix=/opt/python2.6 --with-threads --enable-shared --with-zlib=/usr/include
$ make
$ make install

3. Add Python 2.6 lib to system lib. execute:

$ sudo ln -s /opt/python2.6/lib/libpython2.6.so /usr/lib
$ sudo ln -s /opt/python2.6/lib/libpython2.6.so.1.0 /usr/lib

# Create necessary links and cache
$ sudo /sbin/ldconfig -v

# make a symbolic link to python
$ sudo ln -s /opt/python2.6/bin/python /usr/local/python

4. Check python version use "python -V". If you still see old version of Python, you need to edit /etc/profile (as root), add the following line:

pathmunge /opt/python2.6/bin/

Above setting should be added before the line like:

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

Then re-login system, try "python -V" again. 5. After install yum, try "yum search php"

This is to make sure we did not accidentally mess up "yum", which is the biggest threat when upgrading Python version. If you see no errors, you should be good to start using Python 2.6.

Tagged with:

We hope webmasters to share and promote the good articles ,Please click herecontribute

You need to log in to commentLogin|Register

Be the first to comment!