Yum error – ImportError: No module named cElementTree

来源:互联网 发布:淘宝如何晒单 编辑:程序博客网 时间:2024/05/17 23:29

Got the following error while trying to install a package using yum.

ImportError: No module named cElementTree

Fix:

Here we need to understand, the issue might be due to some python module loading error, as yum works with python. To debug that, we can load the error module manually.

Get into python command line.

 root@test [/]# python

Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> from xml.etree import cElementTreeTraceback (most recent call last):
  File "<stdin>", line 1, in <module>  File "/usr/lib64/python2.6/xml/etree/cElementTree.py", line 3, in <module>    from _elementtree import *ImportError: /usr/lib64/python2.6/lib-dynload/pyexpat.so: symbol XML_SetHashSalt, version EXPAT_2_0_1_RH not defined in file libexpat.so.1 with link time reference>>> quit
You can see there is error while loading the cElementTree python module. Its related to the libexpat.so.1 as you see from error message. There is some version error in this file. We need to find the path of this file.

Use strace

 

strace -o /root/yum.txt yum listSee this file to get the path where yum list access libexpat.so.1
root@test [/]# grep libexpat.so.1 /root/yum.txtopen("/usr/lib64/libexpat.so.1", O_RDONLY) = 13The file /usr/lib64/libexpat.so.1 is corrupted. We can either re-install this lib with rpm/yum or do a fresh install. As yum is broken we cannot easily re-install via rpmWe can install a the expat in a custom location from source.
wget http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/downloadtar -zxf expat-2.1.0.tar.gzcd expat-2.1.0./configure --prefix=/usr/local/myexpatmakemake install
root@test [/]# ll /usr/local/myexpat/lib/libexpat.so.1lrwxrwxrwx. 1 root root 17 Jan 28 19:57 /usr/local/myexpat/lib/libexpat.so.1 -> libexpat.so.1.6.0*We can use this new lib as the server default expat library. For this rename the original lib in the path /usr/lib64 to a different name. If the file /usr/lib64/libexpat.so.1 is a symlink to libexpat.so.1.X.X, then just unlink the file /usr/lib64/libexpat.so.1
mv /usr/lib64/libexpat.so.1 /usr/lib64/libexpat.so.1.OLD
ln -s /usr/local/myexpat/lib/libexpat.so.1.6.0 /usr/lib64/libexpat.so.1Thats it. Yum will now work fine.
root@test [/]# yum list | grep vim-enhancedvim-enhanced.x86_64                     2:7.2.411-1.8.el6               @base
0 0
原创粉丝点击