更新Python后yum失败的解决方法

发布时间:2019-11-06编辑:脚本学堂
更新Python后yum失败的解决方法

更新pythonyum失败的解决方法,遇到类似问题的朋友可以参考下。

今天装RabbitMQ的时候,应该其中有个包依赖Python2.6或更高的版本,系统自带的python2.4,于是就下载了一个Python2.6.1版本安装了,并把Python默认的加载路径/usr/bin/python替换成2.6版本的。没发现异常,后来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.4.3 (#1, Feb  7 2010, 16:05:57)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-53)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq

yum是用Python写的,版本差异导致yum更新失败,解决方法:
此方法是建立在没有卸载系统自带的Python2.4的情况,如果已经卸载,下个2.4的再安装一次。
直接修改
vim /usr/bin/yum

#!/usr/bin/python
修改为
 #!/usr/bin/python2.4  (这个路径根据自己的环境设置或者find / -type f -name python2.4找出路径)
即可,也就是让yum执行的时候指定去寻找2.4版的Python 而不是默认路径下的。
更新Python后不能yum的解决方法 升级Python后不能yum的解决方法 - 李坤山 - 李坤山VS断悬

原文作者:李坤山
博客链接:http://blog.163.com/a12333a