运行yum报错、修复

作者: siediyer 分类: linux 发布时间: 2013-08-11 13:16

现象:运行yum报错,自己弄了二天没有搞定,运维同事弄好了。【自测试,可用】

#########
[ivy@testmimmsTO ~]$ yum
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 the
current version of Python, which is:
2.4.3 (#1, Dec 10 2010, 17:24:35)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]
If you cannot solve this problem yourself, please go to
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq
###########

 

分析Python故障(系统升级所致)
按方案一解决末果

方案一

vi /usr/bin/yum
"将 #!/usr/bin/python 修改为 #!/usr/bin/python2.4"
或者修改:
rm -rf /usr/bin/python
ln -s /usr/bin/python2.4 /usr/bin/python

方案二 重新安装python和yum

1.删除原有Python
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果

2.获取python安装包
mount /dev/cdrom /mnt/cdrom
cd /mnt/cdrom/Server
mkdir /home/***/src
mkdir /home/***/src/pythonrpm
cp python*.rpm /home/****/src/pythonrpm/
cp lib*-python*.rpm /home/****/src/pythonrpm/
cd /home/ivy/src/pythonrpm
rm -v python-ldap*.rpm
rpm -ivh *.rpm
whereis python ##验证安装,返回python: /usr/bin/python2.4 /usr/bin/python,即可

 3.删除原有yum 运行 rpm -qa|grep yum ;运行rpm -e --nodeps 删除所有跟yum有关的包(强制删除)
rm -rf /etc/yum.repos.d/*
whereis yum ##验证当前安装,返回yum: /usr/bin/yum /etc/yum.conf /etc/yum
rpm -qa |grep yum ##验证当前安装包
rpm -qa|grep yum|xargs rpm -e --nodeps ##删除当前安装
whereis yum ##验证删除,返回无结果,若否则运行下命令
whereis yum |xargs rm -rfv

  获取yum安装包(本例源更改为centos,故下载centos安装包及配置文件)
cd /home/***/src
mkdir yumrpm
cd yumrpm
wget http://mirror.centos.org/centos-5/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
wget http://mirror.centos.org/centos-5/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
wget http://mirror.centos.org/centos-5/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
rpm -ivh *.rpm
cp CentOS-Base.repo /etc/yum.repos.d/
yum makecache

测试yum
yum list |grep telnet
yum remove telnet
yum install telnet

  必要时做
cp RPM-GPG-KEY-CentOS-5 /home/***/src
cd /home/***/src
rpm --import RPM-GPG-KEY-CentOS-5

 

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

Title - Artist
0:00