[已解决]yum module doesn't match the current version of Python

更新了python后,yum无法使用。

$ 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.15 |Anaconda, Inc.| (default, May  1 2018, 23:32:55)

[GCC 7.2.0]

If you cannot solve this problem yourself, please go to

the yum faq at:

  http://yum.baseurl.org/wiki/Faq

看了一下python

$ python
Python 2.7.15 |Anaconda, Inc.| (default, May  1 2018, 23:32:55)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

我安装的python是anaconda中的python,直接将python替换掉/usr/bin/python,所以
默认的python是conda中的python,导致现在yum的时候会报错。试了一下网上说的修改/usr/bin/yum 中第一行
#!/usr/bin/python的方法,行不通。
看看yum版本

$ rpm -q yum
yum-3.4.3-154.el7.centos.noarch
image.png

重新装了个python2.6
再将
vi /usr/bin/yum
第一行修改为 /usr/local/bin/python
还没有成功,

重新装yum吧,下载了四个python相关的rpm,重新装一下,

rpm -ivh --force python-tools-2.7.5-68.el7.x86_64.rpm python-2.7.5-68.el7.x86_64.rpm python-libs-2.7.5-68.el7.x86_64.rpm tkinter-2.7.5-68.el7.x86_64.rpm

这里一定要加 --force参数,
然后yum就可以运行了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容