0%

CentOS更换yum源和pip源

描述


CentOS,是基于 Red Hat Linux 提供的可自由使用源代码的企业级 Linux 发行版本;是一个稳定,可预测,可管理和可复制的免费企业级计算平台。


更换yum源

备份

1
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

CentOS 6

1
2
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7

1
2
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

CentOS 8

1
2
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

缓存&更新

1
2
3
yum clean all
yum makecache
yum update

更换pip源

临时使用;

1
pip install some-package -i https://mirrors.aliyun.com/pypi/simple/

设为默认;

1
2
pip install pip -U
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

pip源;

1
2
3
4
5
6
7
8
9
# 豆瓣
https://pypi.doubanio.com/simple/

# 阿里云
https://mirrors.aliyun.com/pypi/simple/

# 清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

欢迎关注我的其它发布渠道