修复Centos yum错误

Yum 报错: No module named yum

Python –V 显示为2.6.
ls /usr/local/lib/python2.6/site-packages/ 下面是空的

手工安装python2.4 rpm:
http://mirror.web-ster.com/centos/5.10/os/i386/CentOS/

修改/usr/bin/yum,第一句改为python2.4

还有下面错误:
Traceback (most recent call last):
File "/usr/bin/yum", line 4, in ?
import yum
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 50, in ?
import comps
File "/usr/lib/python2.4/site-packages/yum/comps.py", line 23, in ?
iterparse = cElementTree.iterparse
AttributeError: 'module' object has no attribute 'iterparse'

仔细检查elementtree已经安装,在comps.py里面加上一句打印,跟好的系统比较了一下:
print cElementTree.__FILE__
发现其指向的文件是个符号链接,这是罪魁祸首,unlink掉ok
unlink /usr/lib/python2.4/site-packages/yum/cElementTree.so

搞定~

你可能感兴趣的:(yum,centos)