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这个目录已经损坏或者不能使用了

若是没了只能从其余服务器上拷贝一个过来,这样就能够了

相关文章
相关标签/搜索