原因为升级python后新建了软连接指向了新版本,除非同时升级yum不然无法使用。需要手动更改报错文件指向新版本后即可解决。
[root@localhost pdserving]# yum install -y tree
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
# 查看路径
[root@localhost pdserving]# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/local/python3.8 /usr/local/python3.7 /usr/share/man/man1/python.1.gz
[root@localhost pdserving]# /usr/bin/python -V
Python 3.7.4
[root@localhost pdserving]# /usr/bin/python2.7 -V
Python 2.7.5
/usr/bin/yum
# 将 第一行的路径改正确就可以了。
[root@localhost pdserving]# vi /usr/bin/yum
#!/usr/bin/python2.7
import sys
try:
import yum
except ImportError:
print >> sys.stderr, """\
/usr/libexec/urlgrabber-ext-down
[root@localhost pdserving]# yum -y install tree
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
[root@localhost pdserving]# vi /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2.7
# A very simple external downloader
# Copyright 2011-2012 Zdenek Pavlas