The centos system is installed with python2.4 by default, so upgrade python to 2.7.5 first. Refer to # Wgethttp: // python.org/ftp/python/2.7.2/Pytho
The centos system is installed with python 2.4 by default, so upgrade python to 2.7.5 first.
Reference: http://gavinshaw.blog.51cto.com/385947/610585
Download the new version of python1: [root @ wangyuelou ~] # Wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz Decompress and compile 1: [root @ wangyuelou ~] # Tar xvf Python-2.7.2.tar.bz2 2: [root @ wangyuelou Python-2.7.2] #. /configure -- prefix =/usr/local/python27 3: [root @ wangyuelou Python-2.7.2] # make 4: [root @ wangyuelou Python-2.7.2] # make install 5: [root @ wangyuelou Python-2.7.2] # ls/usr/local/python27/-al 6: total 28 7: drwxr-xr-x 6 root 4096 Jul 14. 8: drwxr-xr-x 20 root 4096 Jul 14 .. 9: drwxr-xr-x 2 root 4096 Jul 14 Bin 10: drwxr-xr-x 3 root 4096 Jul 14 include 11: drwxr-xr-x 4 root 4096 Jul 14 lib 12: drwxr-xr-x 3 root 4096 Jul 14 share overwrites the original python link 1: [root @ wangyuelou Python-2.7.2] # mv/usr/bin/python/usr/bin/python_old 2: [root @ wangyuelou Python-2.7.2] # ln-s/usr/local/python27/bin/python/usr/bin/3: [root @ wangyuelou Python-2.7.2] # python 4: Python 2.7.2 (default, Jul 14 2011, 00:20:14) 5: [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 6: Type "help", "copyright ", "credits" or "license" for more information. 7: >>> python2.7 can be used normally here, but because yum is used in version 2.4, you need to modify 1: [root @ wangyuelou ~]. # Yum 2: There was a problem importing one of the Python modules 3: required to run yum. the error leading to this problem was: 4: 5: No module named yum 6: 7: Please install a package which provides this module, or 8: verify that the module is installed correctly. 9: 10: It's possible that the above module doesn't match the 11: current version of Python, which is: 12: 2.7.2 (default, Jul 14 2011, 00:20:14) 13: [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] 14: 15: If you cannot solve this problem yourself, please go to 16: the yum faq at: 17: http://wiki.linux.duke.edu/YumFaq 18: 19: 20: [root @ wangyuelou Python-2.7.2] # vim/usr/bin/yum 21: 22 :#! /Usr/bin/python # set this parameter to the 2.4 Location 23: [root @ wangyuelou ~] # Vim/usr/bin/yum 24: 25 :#! /Usr/bin/python2.4 26: [root @ wangyuelou ~] # Yum 27: Loaded plugins: fastestmirror 28: You need to give some command 29: usage: yum [options] COMMAND 30: 31: List of Commands: 32: 33: check-update Check for available package updates 34: clean Remove cached data 35: deplist List a package's dependencies 36: downgrade a package 37: erase Remove a package or packages from your system 38: groupinfo Display details about a package group 39: groupinstall Install the packages in a group on your system 40: grouplist List available package groups 41: groupremove Remove the packages in a group from your system 42: help Display a helpful usage message 43: info Display details about a package or group of packages 44: install Install a package or packages on your system 45: list List a package or groups of packages 46: localinstall Install a local RPM
Yum can be used again
Supplement:
It seems that the newly installed version has taken effect. it should be OK to make a soft connection.
Mv/usr/bin/python-bak
Ln-s/usr/local/bin/python3.0/usr/bin/python
After the upgrade, yum cannot be used. Because yum uses version 2.4, you need to modify the configuration file of yum to identify python in version 2.4.
Vim/usr/bin/yum
Place
#! /Usr/bin/python
Change
#! /Usr/bin/python2.4
You can continue to use yum.