Step 1: uninstall the default yum package installed by rhel to view the yum package rpm-qa | grepyum | xargsrpm-e -- nodeps Step 2: download the new yum package and open the webpage.
Step 1: uninstall rhel's default yum package
View yum package
Rpm-qa | grep yum
Detach
Rpm-qa | grep yum | xargs rpm-e -- nodeps
Step 2: download the new yum package
Open Web http://mirrors.ustc.edu.cn/centos/5/ OS /i386/CentOS/
Find the following rpm package, download and install
Yum-3.2.22-26.el5.CentOS.noarch.rpm
Yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
Yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
And install
Rpm-ivh yum -*
Note: yum and yum-fastestmirror are mutually dependent, so install them at the same time.
Step 3: Download the configuration source of yum
Wget http://www.linuxidc.com/files/2011/05/06/CentOS-Base.repo
Download to the/etc/yum. repos. d/directory.
Step 4: Run yum makecache to generate Cache
[Root @ localhost yum. repos. d] # yum makecache
There was a problem importing one of the Python modules
Required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
Verify that the module is installed correctly.
It's possible that the above module doesn't match
Current version of Python, which is:
2.7.2 (default, Mar 11 2012, 03:08:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]
If you cannot solve this problem yourself, please go
The yum faq:
Http://wiki.linux.duke.edu/YumFaq
The above error occurs when I perform Step 4, because I upgraded python. The solution is as follows:
[Root @ localhost yum. repos. d] # whereis python
Python: /usr/bin/python/usr/bin/python2.4/usr/lib/python1.5/usr/lib/python2.4/usr/local/bin/python2.7/usr/local/bin/python2.7 -config/usr/local/bin/python/usr/local/lib/python2.7/usr/include/python2.4/usr/share/man/man1/python.1.gz
[Root @ localhost yum. repos. d] # vi/usr/bin/yum
#! /Usr/bin/python
Import sys
Change the first line #! /Usr/bin/python2.4, save and exit.
[Root @ localhost yum. repos. d] # yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
Addons | 1.9 kB: 00
Addons/filelists_db | 564 B
Addons/other_db | 552 B: 00
Addons/primary_db | 1.1 kB: 00
Base | 1.1 kB
Base/filelists | 3.0 MB
In this way, the operation is successful.