python升级了yum无法使用怎么解决

lys2018年01月21日 0条评论

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.12 (default, Feb 28 2017, 14:47:53) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

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


这是因为yum命令是基于Python开发的,当Python升级后,yum命令找不到其所依赖的文件导致不可用,yum只能支持python2.6版本

如何解决呢?

编辑yum的配置文件

vi /usr/bin/yum

将文件首行

#!usr/bin/python

修改为

#!/usr/bin/python2.6.6 

:wq保存退出,就可以使用了