yum File “/bin/yum“, line 30 except KeyboardInterrupt, e:

yum list
  File "/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax

原因是主机上,升级了python的版本。查看/usr/bin/下的python信息

# ll /usr/bin/python*
lrwxrwxrwx  1 root root    24 Mar 31  2022 /usr/bin/python -> /etc/alternatives/python
lrwxrwxrwx. 1 root root     9 Apr 14  2021 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root  7144 Oct 14  2020 /usr/bin/python2.7
lrwxrwxrwx  1 root root     9 Aug  6  2021 /usr/bin/python3 -> python3.6
-rwxr-xr-x  2 root root 11328 Oct 14  2020 /usr/bin/python3.6
-rwxr-xr-x  2 root root 11328 Oct 14  2020 /usr/bin/python3.6m

修改/usr/bin/yum的文件,改回python2

#!/usr/bin/python2
import sys
try:
    import yum
except ImportError:
    print >> sys.stderr, """\
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   %s

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

重新执行yum命令

# yum list
Loaded plugins: fastestmirror
Skipping unreadable repository '/etc/yum.repos.d/CentOS-Base.repo'
Skipping unreadable repository '/etc/yum.repos.d/ai-local.repo'
Skipping unreadable repository '/etc/yum.repos.d/docker-ce.repo'
Skipping unreadable repository '/etc/yum.repos.d/epel-testing.repo'
Skipping unreadable repository '/etc/yum.repos.d/epel.repo'
Skipping unreadable repository '/etc/yum.repos.d/grafana.repo'
Skipping unreadable repository '/etc/yum.repos.d/paas.repo'
Determining fastest mirrors

yum命令运行正常。

你可能感兴趣的:(Linux,linux,centos,git)