描述:
將centos7升的python版本由2.7升級到3.6之後,發現yum命令報錯,錯誤如下:
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
問題原因:
yum是使用python2*等開發,在升級到python3之後語法報錯
解決方案:
修改 /usr/bin/yum和/usr/libexec/urlgrabber-ext-down文件,指定使用python2.7作爲yum的解釋器。
具體如下:
vim /usr/bin/yum
#!/usr/bin/python2.7
import sys
try:
import yum
except ImportError:
print >> sys.stderr, """\
vim /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2.7
# A very simple external downloader
# Copyright 2011-2012 Zdenek Pavlas
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public