centos 在执行yum的时候报错
[root@localhost ~]# yum
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.7.8 (default, Nov 24 2015, 15:31:38)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
大多数是python升级导致的
查看python版本
[root@localhost ~]# ls /usr/bin/|grep python
abrt-action-analyze-python
python
python2
python2.6.6
python-config
修改python解释器地址
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这个目录已经损坏或者不能使用了
如果没了只能从其他服务器上拷贝一个过来,这样就可以了