linux执行yum报错: except KeyboardInterrrupt, e

linux执行yum报错:  except KeyboardInterrrupt, e

原因: except KeyboardInterrrupt, e 这个是python 2.7的语法

python3的语法是  except KeyboardInterrrupt as e

yum依赖python2.7 ,例如centos 5版本

解决办法:由于python默认指向了python3导致,临时改成 python指向2.7即可

sudo rm /usr/bin/python

sudo ln -s /usr/bin/python2.7 /usr/bin/python

现在输入 python 显示的版本即是python2.7

 

如何查询python2.7和python3的当前安装目录

分别输入python2.7和python3后,执行下列语句

import sys

sys.exectable 即可显示当前python的安装目录

 

posted @ 2025-09-28 13:19  二师弟tl  阅读(20)  评论(0)    收藏  举报