CentOS系统Python升级后yum不可用的解决办法

来源:互联网 发布:音频算法工程师 编辑:程序博客网 时间:2024/05/02 01:38

通过升级Python后,发现yum命令不能使用了!!!

如何升级Python?详见

CentOS系统升级Python


出现如下错误:

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的配置文件

vi /usr/bin/yum

将文件首行

#!usr/bin/python

修改为

#!/usr/bin/python2.6.6


保存退出!

经测试yum可用




0 0