1. 程式人生 > >python升級導致yum命令無法使用的解決辦法(修改版)

python升級導致yum命令無法使用的解決辦法(修改版)

1、報錯資訊如下:
[[email protected] bin]# yum
[[email protected] local]# yum -y install prce
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:


   No module named yum


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.6.1 (r261:67515, Aug 7 2010, 11:36:17)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]


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




錯誤原因:錯誤資訊描述為 yum 所依賴的python 不相符,請安裝相對應的python即可


2、檢視yum版本
[[email protected] local]# rpm -qa |grep yum
yum-3.2.8-9.el5.centos.1
yum-metadata-parser-1.1.2-2.el5


3、檢視python版本
[[email protected] local]# whereis python
python: /usr/bin/python2.4 /usr/bin/python /usr/lib/python2.4 /usr/local/bin/python2.6 /usr/local/bin/python2.6-config /usr/local/bin/python /usr/local/lib/python2.6 /usr/share/man/man1/python.1.gz



果然裝了兩個版本python


4、執行python,檢視到使用2.6.1的版本
[[email protected] local]# python
Python 2.6.1 (r261:67515, Aug 7 2010, 11:36:17)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>




5、猜測yum呼叫了高版本的python。


6、解決方法:
查詢yum和 yum-updatest檔案,並編輯此py檔案
[
[email protected]
local]# which yum /usr/bin/yum [[email protected] local]# vi /usr/bin/yum
[[email protected] local]# vi /usr/bin/yum-updatest




#!/usr/bin/python
改為:
#!/usr/bin/python2.4


然後儲存OK.

如果不修改/usr/bin/yum ,則yum無法使用

如果不修改/usr/bin/yum-updatest  會出現如下錯誤

 File "/usr/sbin/yum-updatesd", line 35, in <module>
    import dbus
ImportError: No module named dbus

當然,修改完後記著

[[email protected] google_appengine]# /sbin/service yum-updatesd restart
Stopping yum-updatesd:                                     [FAILED]
Starting yum-updatesd:                                     [  OK  ]


補充:yum基於python寫的。