centos No module named yum

centos 在執行yum的時候報錯python

[root@localhost ~]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:vim

   No module named yumcentos

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.7.8 (default, Nov 24 2015, 15:31:38)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]ide

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faqui

大多數是python升級致使的this

查看python版本url

[root@localhost ~]# ls /usr/bin/|grep python
abrt-action-analyze-python
python
python2
python2.6.6
python-config.net

修改python解釋器地址get

vim /usr/bin/yum   修改第一行#!/usr/bin/python改成#!/usr/bin/python2.6.6

若是仍是報錯,須要檢查一下python2.6.6的python是否是能夠正常使用的

在python交互終端上輸入以下命令:

>>> import yum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named yum

查看是否有yum模塊

ls /usr/lib/python2.6/site-packages/yum 看這個目錄下面是否有東西,沒有東西說明下面肯定什麼都沒有了

若是這個目錄存在在檢查一下,python2.6.6是否能夠正常import其餘模塊

例如:import os

若是不能正常import 說明/usr/lib64/python2.6這個目錄已經損壞或者不能使用了

若是沒了只能從其餘服務器上拷貝一個過來,這樣就能夠了

相關文章
相關標籤/搜索