linux - centos下 yum命令无法使用
天蓬老师
天蓬老师 2017-04-17 16:12:59
0
4
957

将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)'**

求解

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
伊谢尔伦

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.

洪涛

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

黄舟

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,2013dnfyum的开发者Seth Vidal因为车祸去世了【默哀】,软件也不再维护。Seth Vidal,2013

yum调用python,启动程序/usr/bin/yum就是一个python脚本。yum是不兼容 Python 2.7的,所以yum不能正常工作,需要指定 yumPython版本 。将文件/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.6code>🎜
左手右手慢动作

!/usr/bin/python2.6 Make sure this line of code is on the first line of the yum file. . . . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!