centos 安装python3导致yum报错
2023-06-13 09:11:17 时间
centos yum报错 File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:
报错:
报错一:
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
报错二:
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
原因:
以上两个报错,是因为我安装python3之后,同时让它作为默认版本软链接到/usr/bin/python
导致。
yum默认使用系统自带的python2.7作为解释器,现在默认python3.6,也就解析2.7语法报错了。
解决方法:
报错一:
编辑/usr/bin/yum
,将第一行原本/usr/bin/python
修改为/usr/bin/python2
即可,如下所示:
#!/usr/bin/python2
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:
...(以下省略)
报错二:
编辑/usr/libexec/urlgrabber-ext-down
,也是把第一行修改为/usr/bin/python2
即可,如下所示:
#! /usr/bin/python2
# A very simple external downloader
# Copyright 2011-2012 Zdenek Pavlas
import time, os, errno, sys
from urlgrabber.grabber import \
_readlines, URLGrabberOptions, _loads, \
PyCurlFileObject, URLGrabError
...(以下省略)
修正之后就可以正常使用yum了! ---by 钢铁 648403020@qq.com 09.28.2020
相关文章
- VirtualBox 安装 CentOS 7 系统并通过主机 ssh 连接虚拟机
- CentOS部署Jumpserver堡垒机
- centos 7.0双网卡主备和负载均衡模式配置(bond0)
- centos 安装 python3_centos运行python脚本
- dracut 查看linux分区,Centos进入dracut模式,报 /dev/centos/swap does not exist,如何恢复[通俗易懂]
- VMware Workstation 16 Pro虚拟机安装与使用【配置CentOS】教程
- Centos 6.9_centos iptables
- centos 7 关闭 firewall、iptables详解程序员
- 在CentOS 8上安装htop的教程
- 查看CentOS版本:Linux解决方案(linux查看centos版本)
- 查看CentOS系统下mysql版本:从运维的角度(centos查看mysql版本)
- 的关系Centos与Linux的同一路——开放的未来(centos与linux)
- 在 CentOS 6 系统上安装最新版 Python3 软件包的 3 种方法
- CentOS系统如何连接MySQL数据库(centos连mysql)
- CentOS进驻MySQL轻松让您拥有数据库管理权(centos进mysql)
- CentOS上安装MySQL简单又安全(centos加mysql)
- centOS安装MySQL更为稳定便捷的选择(centos-mysql)
- CentOS下停止Tomcat运行脚本代码