yum错误'module' object has no attribute 'iterparse'解决方法

来源:互联网 发布:js 点击按钮执行函数 编辑:程序博客网 时间:2024/06/05 04:00

    运行yum时出现下面的错误:

    root@server [~]# yum
    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 49, 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'

    这个问题提到了cElementTree,搜了一下发现位于Python的cElementTree模块,重新安装这个模块(直接卸载会有yum依赖关系):

    rpm -ivh --force http://mirrors.sohu.com/centos/5.6/os/x86_64/CentOS/python-elementtree-1.2.6-5.x86_64.rpm

    我的系统是CentOS 5.6,系统架构是x86_64,其余系统、架构参照修改,也可以下载对应的rpm包安装,注意--force选项。

    安装完之后,再运行yum,原来的错误已经消失,可能还会出现其他模块找不到的错误,一一按照提示安装,譬如,我还出现urlgrabber、iniparse找不到的错误:

    rpm -ivh --force http://mirrors.sohu.com/centos/5.6/os/x86_64/CentOS/python-urlgrabber-3.1.0-6.el5.noarch.rpm

    rpm -ivh --force http://mirrors.sohu.com/centos/5.6/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm   

原创粉丝点击