Home  >  Q&A  >  body text

linux - centos下 yum命令无法使用

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

求解

天蓬老师天蓬老师2743 days ago955

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦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.

    reply
    0
  • PHP中文网

    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

    reply
    0
  • 黄舟

    黄舟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,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.6🎜

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 16:14:59

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

    reply
    0
  • Cancelreply