When setting up a test environment on CentOS, when you encounter the need to upgrade the Python version, the entire upgrade process is documented:
The Python version that comes with CentOS5 is 2.4, but many Python-based applications now require a Python version higher than 2.4. When upgrading the Python version, you must not uninstall the Python 2.4and install python2.7, which may cause many programs to fail, even connect to the network, and finally have to reinstall the system. The conservative approach is to install python2.7 's source package directly, which is Python's two-version coexistence. (because there are many programs in CentOS that rely on Python, it's best not to try to uninstall python2.4).
(1) Download/install Python
Download python2.7.2.tar.bz2 (http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2)
$tar JXVF python2.7.2.tar.bz2 $CD Python2.7.2
$./configure $make && make install
Since then, the python2.7 installation path defaults to the/usr/local/lib/python2.7
To view the Python version:
$/usr/local/bin/python2.7-v
(2) Establish a soft connection so that the system default Python points to python2.7
Under normal circumstances, even if the python2.7 installation succeeds, the system will point to Python is still version 2.4, considering that Yum is based on python2.4 to work properly, not easy to uninstall. How do you point to the system default Python to version 2.7?
Mv/usr/bin/python/usr/bin/python.bak (or Rm-rf/usr/bin/python)
Ln-s/usr/local/bin/python2.7/usr/bin/python
Verify that the Python point is successful python-v
(3) Fix system python soft link to python2.7 version, Yum does not work properly
Method:
$vi/usr/bin/yum Change the text editing display #/usr/bin/python to #/usr/bin/python2.4, save the changes.