yum 安裝損壞

yum 安裝損壞

我嘗試使用 yum update 更新伺服器上的 CentOS,但出現以下錯誤:

Traceback (most recent call last):
  File "/usr/bin/yum", line 4, in <module>
    import yum
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 59, in <module>
    import config
  File "/usr/lib/python2.7/site-packages/yum/config.py", line 30, in <module>
    from parser import ConfigPreProcessor, varReplace
  File "/usr/lib/python2.7/site-packages/yum/parser.py", line 4, in <module>
    import urlgrabber
  File "/usr/lib/python2.7/site-packages/urlgrabber/__init__.py", line 55, in <module>
    from grabber import urlgrab, urlopen, urlread
  File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1616
    errstr = str(e.args[1]) or pyerr2str.get(errcode, '<Unknown>')

我只能猜測我的Python有一些嚴重的問題。我該如何解決這個問題?

PS 我對基於 Debian 的系統有經驗,但對基於 rpm 的系統沒有經驗。這是我的第一台基於 rpm 的伺服器,所以請寬容。

編輯:

[root@WEBITCONSULT ~]# yum repolist
Traceback (most recent call last):
  File "/usr/bin/yum", line 4, in <module>
    import yum
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 59, in <module>
    import config
  File "/usr/lib/python2.7/site-packages/yum/config.py", line 30, in <module>
    from parser import ConfigPreProcessor, varReplace
  File "/usr/lib/python2.7/site-packages/yum/parser.py", line 4, in <module>
    import urlgrabber
  File "/usr/lib/python2.7/site-packages/urlgrabber/__init__.py", line 55, in <module>
    from grabber import urlgrab, urlopen, urlread
  File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1616
    errstr = str(e.args[1]) or pyerr2str.get(errcode, '<Unknown>')
         ^
SyntaxError: invalid syntax

答案1

嘗試按照以下方式清理 yum 快取和元資料。

yum clean metadata && yum clean all

重建 RPM 資料庫。

rm -f /var/lib/rpm/__db*
rpm -vv --rebuilddb

如果您仍然遇到問題,請包括yum repolist此處的輸出

相關內容