yum list
File "/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
The reason is that the version of python has been upgraded on the host. View python information under /usr/bin/
# 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
Modify the /usr/bin/yum file and change it back to 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.
Re-execute the yum command
# 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
The yum command works fine.