Centos中Python升级为3.X时yum出现except OSError, e: ^ SyntaxError: invalid syntax问题

本文介绍如何在CentOS7中将Python升级到3.5.2版本,并修复了由于升级导致的yum无法正常工作的问题。通过修改特定文件中的Python解释器路径,最终解决了错误。

CentOS 7升级Python3.5。2后,需要/usr/bin/python创建了一个指向Python 3的软连接,然后将/usr/bin/yum的顶部的:

!/usr/bin/python

改成了

!/usr/bin/python2.7

后,运行yum,还是出现了以下错误:

[root@master ~]# yum -y groupinstall “X Window System”

 File "/usr/libexec/urlgrabber-ext-down", line 28

    except OSError, e:

                  ^

SyntaxError: invalid syntax


解决方案:

1.


vim /usr/libexec/urlgrabber-ext-down

将/usr/bin/python改为/usr/bin/python2.7

2.

vim /usr/bin/yum-config-manager

解决办法同上: #!/usr/bin/python换成#!/usr/bin/python2.7 

sudo yum install python2 Loaded plugins: fastestmirror, langpacks Determining fastest mirrors Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" * base: mirrors.bupt.edu.cn * extras: mirrors.bupt.edu.cn * updates: mirrors.aliyun.com http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. http://mirrors.bupt.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 403 - Forbidden Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. http://mirrors.njupt.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 403 - Forbidden Trying other mirror. http://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. http://mirrors.163.com/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. base | 3.6 kB 00:00 http://mirrors.ustc.edu.cn/centos/7.9.2009/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. http://mirrors.huaweicloud.com/centos/7.9.2009/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. extras | 2.9 kB 00:00 http://mirrors.huaweicloud.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. http://mirrors.ustc.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. updates | 2.9 kB 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 Exiting on user cancel
最新发布
08-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sunxiaopengsun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值