1. 程式人生 > >CentOS yum No module named urlgrabber報錯解決方案

CentOS yum No module named urlgrabber報錯解決方案

我的環境版本資訊如下:

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即可