将centos升级,python也跟着升级到2.6版本,
然后尝试使用yum命令提示版本不对,于是使用vi/usr/bin/yum修改首行
将#!/usr/bin/python 改为#!/usr/bin/python2.6
接着重启服务器,
然后再使用yum命令出现以下错误
**/usr/bin/yum: line 3: import: command not found
/usr/bin/yum: line 4: try:: command not found
/usr/bin/yum: line 5: import: command not found
/usr/bin/yum: line 6: except: command not found
/usr/bin/yum: line 24: syntax error near unexpected token `('
/usr/bin/yum: line 24: `""" % (sys.exc_value, sys.version)'**
求解
伊谢尔伦2017-04-17 16:14:59
It is recommended that you change the first line of /usr/bin/yum back to #!/usr/bin/python, and then use the command to check the version number of yum: rpm -q yum, use yum with an absolute path,
This is my system Situation:
ls /usr/bin/python
python python2 python2.6
rpm -q yum
yum-3.2.29-60.el6.centos.noarch
Check what version of yum you have and upgrade it.
PHP中文网2017-04-17 16:14:59
It seems that the system does not run yum as a python script, but as a shell...
You can run python /usr/bin/yum and see
黄舟2017-04-17 16:14:59
It is recommended to try dnf
. The developer of yum
, Seth Vidal, passed away in a car accident [silence] and the software is no longer maintained. Seth Vidal,2013dnf
,yum
的开发者Seth Vidal因为车祸去世了【默哀】,软件也不再维护。Seth Vidal,2013
yum
调用python,启动程序/usr/bin/yum
就是一个python
脚本。yum
是不兼容 Python 2.7
的,所以yum
不能正常工作,需要指定 yum
的Python
版本 。将文件/usr/bin/yum
头部的 #!/usr/bin/python
改成#!/usr/bin/python2.6.6
yum
calls python, and the startup program /usr/bin/yum
is a python
script. yum
is not compatible with Python 2.7
, so yum
cannot work properly. You need to specify Python of yum
version. Change the #!/usr/bin/python
in the header of the file /usr/bin/yum
to #!/usr/bin/python2.6.6
🎜ringa_lee2017-04-17 16:14:59