Python升级导致yum命令不能使用

2020-01-09 16:54:03 浏览数 (1)

错误信息如下:

[root@bjzw-mcu01-x86p-app01 ~]# yum -y update 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.3 (default, Jul  8 2014, 22:55:29) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]

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

排错思路:

1.查看yum的版本号

[root@bjzw-mcu01-x86p-app01 ~]# rpm -qa | grep yum yum-3.2.29-60.el6.centos.noarch yum-plugin-fastestmirror-1.1.30-30.el6.noarch yum-utils-1.1.30-30.el6.noarch yum-plugin-security-1.1.30-30.el6.noarch yum-metadata-parser-1.1.2-16.el6.x86_64

2.查看python的版本号,发现有2种版本号

[root@bjzw-mcu01-x86p-app01 ~]# whereis python python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6 /usr/local/python2.7 /usr/share/man/man1/python.1.gz

3. 查看当前所使用的版本

[root@bjzw-mcu01-x86p-app01 ~]# python Python 2.7.3 (default, Jul  8 2014, 22:55:29) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

4.修改yum命令所使用的python版本号

[root@bjzw-mcu01-x86p-app01 ~]# vim /usr/bin/yum

#!/usr/bin/python2.6

0 人点赞