把 CentOS6.5 默认的 python2.6 升级到了 python2.7,然后运行 yum 命令的时候就出现了错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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.13 (default, Aug 18 2017, 21:52:09) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] If you cannot solve this problem yourself, please go to the yum faq at: https://yum.baseurl.org/wiki/Faq |
原因是因为 yum 是用 python 写的,并不兼容 2.7,所以运行会报错。解决办法是修改 yum 源文件,指定 python 版本为老版本。
前提是升级的时候按照要求备份了老版本的软链接。
1 |
vi /usr/bin/yum |
修改第一行
1 |
#!/usr/bin/python |
1 |
#!/usr/bin/python26 |
搞定
------------------------------------------------------------这里是我的底线------------------------------------------------------------
评论