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命令运行正常。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值