centos 使用yum安装python3报错+更换yum国内源解决
文章目录一、问题由来:二、步骤:1、访问清华镜像源:2、点击问号帮助:3、建议先备份 CentOS-Base.repo4、更改:/etc/yum.repos.d/CentOS-Base.repo5、最后,更新软件包缓存6、安装python3一、问题由来:今天购买了一台vps测试学习下,结果使用yum命令安装python3,给我一堆错误,然后刚开始以为没有网络,使用curl访问百度什么都没有问题。然
·
文章目录
一、问题由来:
今天购买了一台vps测试学习下,结果使用yum命令安装python3,给我一堆错误,然后刚开始以为没有网络,使用curl访问百度什么都没有问题。然后觉得是yum源 的问题。所以百度搜索了下配置yum源。
最后问题解决,整理下这个文章,方便下次再遇到可以快速解决。
二、步骤:
1、访问清华镜像源:
2、点击问号帮助:
3、建议先备份 CentOS-Base.repo
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
4、更改:/etc/yum.repos.d/CentOS-Base.repo
编辑/etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
将所有的mirrorlist这一行注销,将所有的baseurl改为清华镜像地址,保存即可
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
将里面的两行改为我的这种:
或者直接复制官方的(全文替换,我的正好是centos7,可以全文替换,不是7版本的系统,还是,一个一个替换吧):
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
5、最后,更新软件包缓存
sudo yum makecache
6、安装python3
yum install python3
参考文章:
https://mirrors.cnnic.cn/help/centos/
https://blog.csdn.net/xiaojin21cen/article/details/84726193
更多推荐
已为社区贡献2条内容
所有评论(0)