CentOS7 升级python3.7.3后yum损坏问题

1、使用yum报错:

[root@localhost ~]# yum

显示以下错误

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

2、vim /usr/bin/yum
打开yum文档,输入以下命令打开

 vim /usr/bin/yum

修改python头部python为python2.7 视原系统情况而设

#!/usr/bin/python2.7.5
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:

修改之后输入:wq退出并保存:

:q    ##退出,在文件内容没有被改变时使用

:q!     ##强制退出不保存,在改变文件后不想保存时使用

:wq    ##退出保存

:wq!   ##强制退出保存,在对只读文件编写时使用,注意,所编辑的只读文件必须是当前用户的文件;或者当前操作的用户是root

3、再次查看yum是否可用

[root@localhost ~]# yum
Loaded plugins: fastestmirror, langpacks
You need to give some command
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package‘s dependencies

你可能感兴趣的:(CentOS7 升级python3.7.3后yum损坏问题)