Centos5.x under upgrade python to python version 2.7 tutorial

  • 2020-04-02 14:36:12
  • OfStack

First go to the official website to download python version 2.7.3, compile and install


$wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
$tar zxvf Python-2.7.3.tgz
$cd Python-2.7.3
$./configure
$make && make install

It then backs up the original python and makes a soft connection to python2.7 to the new location

$mv /usr/bin/python /usr/bin/python.bak
$ln -s /usr/local/bin/python2.7 /usr/bin/python
$python -V

The version prompt is 2.7.3
Change yum to make it work

$vim vim /usr/bin/yum

Change #/usr/bin/python to #/usr/bin/python2.4 so yum works

Install easy_install


$yum install python-setuptools

Then install python-setuptools go to pypi website and download python-setuptools. The version should be consistent with the version of yum, otherwise it will appear when running:

$ easy_install rsa
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

And then:

$wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c5.tar.gz
$tar zxvf setuptools-0.6c5.tar.gz
$cd setuptools-0.6c5
$python setup.py install

This makes it easy to install python libraries using easy_install


Related articles: