[root@46500f7f3367 ]# yum install httpd
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* extras: ap.stykers.moe
* updates: mirror.jdcloud.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-90.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-90.el7.centos for package: httpd-2.4.6-90.el7.centos.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.4.6-90.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-90.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-90.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-90.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-5.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package centos-logos.noarch 0:70.0.6-3.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-90.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
httpd x86_64 2.4.6-90.el7.centos base 2.7 M
Installing for dependencies:
apr x86_64 1.4.8-5.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
centos-logos noarch 70.0.6-3.el7.centos base 21 M
httpd-tools x86_64 2.4.6-90.el7.centos base 91 k
mailcap noarch 2.1.41-2.el7 base 31 k
Transaction Summary
==============================================================================================================
Install 1 Package (+5 Dependent packages)
Total download size: 24 M
Installed size: 31 M
Is this ok [y/d/N]: y
Downloading packages:
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
在执行yum命令时忽然发现出现以下报错:
yum list
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
原因:
这是因为yum采用Python作为命令解释器,这可以从/usr/bin/yum文件中第一行#!/usr/bin/python发现。而python版本之间兼容性不太好,使得2.X版本与3.0版本之间存在语法不一致问题。而CentOS 7自带的yum采用的是python2.7,当系统将python升级到3.4后,出现语法解释错误。
解决办法:
一是升级yum。
二是修改yum的解释器为旧版本python2.7,即将连接文件/usr/bin/python连接回/usr/bin/python2.7。治标不治本,不推荐。
三是在设置里更改解释器设置,即修改/usr/bin/yum文件,指定使用python2.7作为yum的解释器:
将第一行”#!/usr/bin/python” 改为 “#!/usr/bin/python2″即可。
安装软件时又会出现另一种报错
Downloading packages:
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
问题与前面一个一样,因此解决办法也是一样的:
vi /usr/libexec/urlgrabber-ext-down
将第一行”#!/usr/bin/python” 改为 “#!/usr/bin/python2″即可。
版权声明:本文为weixin_43866211原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。