有时使用yum install时会出现如下错误,导致软件无法安装。

Loaded plugins: fastestmirror
Cleaning repos: base epel extras mysql-connectors-community mysql-tools-community
: mysql56-community updates
14 metadata files removed
0 sqlite files removed
0 metadata files removed
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql56-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax


Exiting on user cancel

这个yum的一个bug,解决的办法是修改/usr/lib/python2.7/site-packages/urlgrabber/grabber.py文件。

elif errcode == 42:
  # this is probably wrong but ultimately this is what happens
  # we have a legit http code and a pycurl 'writer failed' code
  # which almost always means something aborted it from outside
  # since we cannot know what it is -I'm banking on it being
  # a ctrl-c. XXXX - if there's a way of going back two raises to
  # figure out what aborted the pycurl process FIXME
  raise KeyboardInterrupt

修改后:

#elif errcode == 42:
  # this is probably wrong but ultimately this is what happens
  # we have a legit http code and a pycurl 'writer failed' code
  # which almost always means something aborted it from outside
  # since we cannot know what it is -I'm banking on it being
  # a ctrl-c. XXXX - if there's a way of going back two raises to
  # figure out what aborted the pycurl process FIXME
  #raise KeyboardInterrupt

然后切换到root用户,执行以下命令:

yum clean metadata

yum clean all

yum upgrade

执行完后,重新执行安装命令,大多数人应该都解决了,但是博主运气较差,并没有解决。

后来各种鼓捣,又修改了/usr/bin/yum文件,将第一行修改为如下内容:

#!/usr/bin/python2

但是新问题又来了:

[root@iz2ze3g36wzfbgvzqas89uz conf]# yum -y install php
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                                            ^
SyntaxError: invalid syntax

解决方法就是,修改/usr/libexec/urlgrabber-ext-down文件,将第一行修改为如下内容:

#! /usr/bin/python2

至此,终于可以愉快的安装软件了。

转载于:https://www.cnblogs.com/feilstar/p/10284890.html

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐