No module named 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.6 (default, Sep 29 2018, 18:12:27)
[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:
http://yum.baseurl.org/wiki/Faq

这是因为升级python后, 没有指定yum用系统自带python版本导致的. yum和Python有依赖关系,yum是python的模块. 

[root@centos-A ~]# python -V     # 果然是有人升级版本了, centos 6 默认是2.6的
Python 2.7.6
[root@centos-A ~]# which python
/usr/local/bin/python
[root@centos-A ~]# ll /usr/local/bin/python
lrwxrwxrwx 1 root root 7 Sep 29 18:13 /usr/local/bin/python -> python2
[root@centos-A ~]# ll /usr/local/bin/python2
lrwxrwxrwx 1 root root 9 Sep 29 18:13 /usr/local/bin/python2 -> python2.7
[root@centos-A ~]# which python2.6
/usr/bin/python2.6
[root@centos-A ~]# 
[root@centos-A ~]# vim /usr/bin/yum  ###修改这个文件, 把第一行 #!/usr/bin/python 改为 #!/usr/bin/python2.6
#!/usr/bin/python2.6

看这样就好了, 升级Python我之前也写过, 可以参考一下

猜你喜欢

转载自www.cnblogs.com/mingetty/p/10419688.html
今日推荐