安装mysql-devel时报错,由于yum包管理是使用python2.x写的,到python3.1后,语法兼容性导致问题出现
[root@VM_0_15_centos ~]# yum install mysql-devel
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
解决方法:
修改yum配置文件,将python版本指向以前的旧版本
查看旧版本:
[root@VM_0_15_centos bin]# cd /usr/bin
[root@VM_0_15_centos bin]# ll pyth*
lrwxrwxrwx 1 root root 24 Dec 29 16:21 python -> /usr/local/bin/python3.7
lrwxrwxrwx. 1 root root 9 Jan 9 2018 python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 Aug 4 2017 python2.7
[root@VM_0_15_centos bin]#
vi /usr/bin/yum
#!/usr/bin/python2.7
[root@VM_0_15_centos bin]# vi /usr/bin/yum
#!/usr/bin/python2.7
import sys
try:
import yum
except ImportError:
print >> sys.stderr, """\
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
%s
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
%s
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
""" % (sys.exc_value, sys.version)
sys.exit(1)
sys.path.insert(0, '/usr/share/yum-cli')
try:
import yummain
yummain.user_main(sys.argv[1:], exit_code=True)
except KeyboardInterrupt, e:
print >> sys.stderr, "\n\nExiting on user cancel."
sys.exit(1)
~
~
~
~
~
修改urlgrabber-ext-down文件,更改python版本
vi /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python2.7
[root@VM_0_15_centos bin]# vi /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
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
import time, os, errno, sys
from urlgrabber.grabber import \
_readlines, URLGrabberOptions, _loads, \
PyCurlFileObject, URLGrabError
def write(fmt, *arg):
try: os.write(1, fmt % arg)
except OSError, e:
if e.args[0] != errno.EPIPE: raise
sys.exit(1)
class ProxyProgress:
def start(self, *d1, **d2):
self.next_update = 0
def update(self, _amount_read):
t = time.time()
if t < self.next_update: return
self.next_update = t + 0.31
write('%d %d\n', self._id, _amount_read)
def main():
import signal
signal.signal(signal.SIGINT, lambda n, f: sys.exit(1))
在安装mysql-devel时遇到错误,由于yum依赖的python版本与系统当前版本不兼容。解决方案是修改yum配置文件和urlgrabber-ext-down文件,将python版本指定为2.7来保持兼容。

329

被折叠的 条评论
为什么被折叠?



