问题现象

CentOS7升级python3以后,有可能导致yum命令报错,报错截图如下:

  解决YUM报错except KeyboardInterrupt,_python


问题原因

python3与python2有个别语法不一致,会导致脚本出错。查看YUM脚本:

  解决YUM报错except KeyboardInterrupt,_python_02

使用系统自带python,当系统默认python是python3时,会导致命令错误。


解决方法

1、修改系统默认python

l -snf /usr/bin/python2 /usr/bin/python

查看当前python环境:

  解决YUM报错except KeyboardInterrupt,_centos_03

执行yum命令:

  解决YUM报错except KeyboardInterrupt,_python_04




2、修改yum脚本

sed -i 's/python/python2/g' /usr/bin/yum

查看当前python环境:

  解决YUM报错except KeyboardInterrupt,_centos_05

查看Yum脚本:

  解决YUM报错except KeyboardInterrupt,_python_06

执行yum命令:

  解决YUM报错except KeyboardInterrupt,_centos_07