更換yum源
1、備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下載新的 CentOS-Base.repo
# CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
3、生成緩存
yum makecache
4、yum源推薦
yum源大全:http://www.360doc.com/content/19/0706/22/54508727_847143477.shtml
5、牆裂推薦,中科大的源:https://mirrors.ustc.edu.cn/
步驟:點擊配置軟件源--> CentOS 源使用幫助 --> 直接復制Centos對應文件運行即可(如下) --> 運行測試
Ps:上面都不用看直接運行下面對應系統中的代碼
對於 CentOS 8,使用以下命令替換默認的配置
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
-i.bak \
/etc/yum.repos.d/CentOS-Base.repo \
/etc/yum.repos.d/CentOS-Extras.repo \
/etc/yum.repos.d/CentOS-AppStream.repo
對於 CentOS 6、7,使用以下命令替換默認配置
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
-i.bak \
/etc/yum.repos.d/CentOS-Base.repo
以上命令只替換了默認啟用的倉庫。替換之后請運行 yum makecache 更新緩存。
這里注意了,不同版本的 Centos8 可能會提示找不到目錄,那是因為版本不同,文件名有差異,進入目錄之后,對着名字把這里三個目錄文件的名字改一下就好了。
更換pip源
[root@localhost ~]# cd ~
[root@localhost ~]# mkdir .pip
[root@localhost ~]# cd .pip
[root@localhost .pip]# vim pip.conf
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
若要臨時使用:
pip install some-package -i https://mirrors.aliyun.com/pypi/simple/
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/
