版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。 https://blog.csdn.net/kucoll/article/details/81585117
我的环境版本信息如下:
CentOS release 6.10 (Final)
执行任何yum命令都出现错误:yum No module named urlgrabber,详细错误信息如下;
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.7.5 (default, Feb 11 2014, 07:46:25)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-13)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
原因大概是在安装了多个版本的python后造成的
解决办法:重新安装urlgrabber的rpm包即可
操作步骤:
1:卸载现有的urlgrabber包(如果存在)
# 查看是否已安装urlgrabber,笔者的是python-urlgrabber-3.9.1-11.el6.noarch这个版本
rpm -qa | grep urlgrabber
# 卸载python-urlgrabber-3.9.1-11.el6.noarch
rpm -e --nodeps python-urlgrabber-3.9.1-11.el6.noarch
2:在官网下载对应版本的urlgrabber包
curl -O http://mirror.centos.org/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
3:重新安装下载好的urlgrabber
rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
4:如果安装urlgrabber出现如下错误(没有则忽略)
error: Failed dependencies:
python-pycurl is needed by python-urlgrabber-3.9.1-11.el6.noarch
# 需要安装python-pycurl.rpm包,从这里下载
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
# 安装python-pycurl包
rpm -ivh python-pycurl-7.19.0-9.el6.x86_64.rpm
最后,重新使用yum即可