如何修复 yum 错误:没有名为 CElementTree 的模块?

如何修复 yum 错误:没有名为 CElementTree 的模块?

我在使用 yum 时遇到以下问题:

$ yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named cElementTree

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.4.3 (#1, Feb 22 2012, 16:06:13) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq

我的操作系统:CentOS 版本 5.8(最终版)

尝试从 RPM 包手动安装 python-elementtree 时出现以下错误:

$ sudo rpm -i http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
package python-elementtree-1.2.6-7.el4.rf.i386 (which is newer than python-elementtree-1.2.6-5.i386) is already installed
$ sudo rpm -i http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm

相关链接:

答案1

嗯,python-elementtree 还安装吗?cEleementTree 模块应该位于/usr/lib64/python2.4/site-packages/cElementTree.so(32 位系统上的 /usr/lib/...)。该文件还存在吗?

如果缺少该软件包,您可以使用 rpm 重新安装:

x86_64:

rpm -i http://mirror.centos.org/centos-5/5/os/x86_64/CentOS/python-elementtree-1.2.6-5.x86_64.rpm

i386:

rpm -i http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm

答案2

解决方案

尝试python-elementtree手动下载并安装:

x86_64

wget http://mirrors.usc.edu/pub/linux/distributions/centos/5.8/os/x86_64/CentOS/python-elementtree-1.2.6-5.x86_64.rpm
sudo rpm -Uvh python-elementtree-*.rpm

i386

wget http://mirrors.usc.edu/pub/linux/distributions/centos/5.8/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
sudo rpm -Uvh python-elementtree-*.rpm

故障排除

错误:“软件包 python-elementtree-1.2.6-7.el4.rf.i386(比 python-elementtree-1.2.6-5.i386 更新)已安装”或类似信息

尝试替换该包,即使它是通过以下方式安装的:

sudo rpm -iv --replacepkgs python-elementtree-*.rpm

或者:

sudo rpm -iv --replacefiles python-elementtree-*.rpm

或者最后:

sudo rpm -iv --force python-elementtree-*.rpm

看:--replacepkgs:即使已安装也安装该软件包

相关内容