No module named yum 报错

今天在测试服务器用yum的时候报错了: html

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:python

No module named yumvim

Please install a package which provides this module, or
verify that the module is installed correctly.centos

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/Faqpython2.7

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

[root@centos-A ~]# python -V     # 果真是有人升级版本了, centos 6.9 默认是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以前也写过, 能够参考一下测试

http://www.javashuo.com/article/p-hpxlopio-ew.htmlui