一、背景
好久没用服务器yum了,今天清理不用软件,发现yum报错了。。
系统:CentOS release 6.8
报错如下:
[root@VM_0_9_centos yum]# 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.7.15 (default, Sep 5 2018, 10:00:40) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
搜索问题,大概都是安装了新版python导致无法使用。可我已经早已经修改了python路径,查看/usr/bin/yum中python路径并没有问题。
二、解决问题
没办法只能重新下载yum包,重新安装。
下载地址:http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/
yum-3.2.29-81.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-utils-1.1.30-41.el6.noarch.rpm
yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm
yum-plugin-aliases-1.1.30-41.el6.noarch.rpm
执行rpm安装
rpm -Uvh --replacepkgs yum*.rpm
安装完毕重新修改yum程序的python指向,重新安装后会指向默认的python可能是最新版本,我这里还改为2.6.6
这里最好看一下python路径
whereis python
或者 ll /usr/bin/python*
/etc/bin/yum
执行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 urlgrabber 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.6.6 (r266:84292, Aug 18 2016, 15:13:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
这里提示缺少了urlgrabber
继续下载
wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm rpm -Uvh --replacepkgs python-urlgrabber-3.9.1-11.el6.noarch.rpm Preparing... ########################################### [100%] 1:python-urlgrabber ########################################### [100%]
这里执行终于不再报错。
三、总结
每次升级python都会遇到这种问题,但是这次却不是python路径的问题。
这可能是中间不知道给我卸了什么包,导致yum无法运行。
解决问题有些曲折。。作此记录,供大家参考。
精彩评论