Python

RHEL 6.x - yum 給出“ImportError: No module named cElementTree”錯誤

  • August 17, 2017

我正在對一組 150 台伺服器進行一組更改。所有系統都能夠通過 成功下載並安裝一組特定的 RPM yum,除了一個。在這個特定的系統中,“clean”之外的所有 yum 命令都將以下內容轉儲到螢幕上:

[root@dev1v ~]# yum install sssd
Loaded plugins: rhnplugin
/usr/lib64/python2.6/xmlrpclib.py:612: DeprecationWarning: The xmllib module is obsolete.  Use xml.sax instead.
 import xmllib # lazy subclassing (!)
Traceback (most recent call last):
 File "/usr/bin/yum", line 29, in <module>
   yummain.user_main(sys.argv[1:], exit_code=True)
 File "/usr/share/yum-cli/yummain.py", line 285, in user_main
   errcode = main(args)
 File "/usr/share/yum-cli/yummain.py", line 136, in main
   result, resultmsgs = base.doCommands()
 File "/usr/share/yum-cli/cli.py", line 434, in doCommands
   self._getTs(needTsRemove)
 File "/usr/lib/python2.6/site-packages/yum/depsolve.py", line 99, in _getTs
   self._getTsInfo(remove_only)
 .
 .
 .
 File "/usr/lib/python2.6/site-packages/yum/repoMDObject.py", line 124, in __init__
   self.parse(srcfile)
 File "/usr/lib/python2.6/site-packages/yum/repoMDObject.py", line 140, in parse
   parser = iterparse(infile)
 File "/usr/lib/python2.6/site-packages/yum/misc.py", line 1169, in cElementTree_iterparse
   _cElementTree_import()
 File "/usr/lib/python2.6/site-packages/yum/misc.py", line 1164, in _cElementTree_import
   import cElementTree
ImportError: No module named cElementTree

我試過了:

  • 百勝清潔
  • expat通過 RPM… 、 part ofpython等手動重新安裝零碎。
  • 重建 RPM 數據庫

有什麼想法嗎?

修復:

顯然,該系統上的 Oracle 安裝將 Oracle 的路徑注入 LD_LIBRARY_PATH …

[root@dev1v etc]# export 
declare -x LD_LIBRARY_PATH="/home/oracle/app/oracle/product/11.2.0/client_1/lib"

取消設置變數允許 yum 再次正常執行。

嗯,在 python 2.6 中,cElementTree 位於 /usr/lib64/python2.6/xml/etree/cElementTree.py 中,它是 python 包的一部分。您到達import cElementTreeyum 程式碼中的事實表明這xml.etree似乎失去了。

嘗試通過手動下載 rpm 並使用rpm -Uvh.

如果這不起作用,如果你import xml.etree.cElementTree在 python shell 中會發生什麼?說什麼rpm --verify python

引用自:https://serverfault.com/questions/482280