[技术]CentOS更换yum源和pip源(阿里源)

作者: hackliu 分类: 技术文章 发布时间: 2020-04-22 00:14

1、简介

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

2.更换yum源(阿里源)

2.1、备份

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

2.2、下载新的源文件

        CentOS 6

             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

            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

            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

3、生产缓存

            yum clean all

        yum makecache

4、执行更新

            yum update

二、更新pip源

# 豆瓣

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/

临时使用

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

设为默认

升级 pip 到最新的版本后进行配置:

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

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

邮箱地址不会被公开。 必填项已用*标注