For some reasons, whether it is the network or something, the access to foreign sources is very slow from time to time. At this time, we can replace the foreign sources with domestic sources to improve the download speed.
yum source replacement
Environment: centos7 (if your distribution is not this, this method is not guaranteed to succeed)
Backup the original yum file
# mkdir yumrepo
# mv /etc/yum.repos.d/* yumrepo/
Download the yum source configuration file
The yum source I mainly use is 163 and Alibaba Cloud. The download method of the configuration file is as follows:
163 yum source
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -O /etc/yum.repos.d/CentOS7-Base-163.repo
aliyun yum source
# wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base-aliyun.repo
Generate cache
Generate a cache to confirm that the downloaded source can be used without problems
# yum clean all # yum makecache
pip source replacement
pip source
I mainly use the following pip sources:- Douban: http://pypi.douban.com/simple/
Tsinghua: https://pypi.tuna.tsinghua.edu.cn/simple
Instructions
- Temporary use For
temporary use, you can use -i to add source, such as: pip install gevent -i https://pypi.tuna.tsinghua.edu.cn/simple - Permanent changes
If you want to make permanent changes, you need to modify the configuration file.linux modify the configuration file
Modify the ~/.pip/pip.conf configuration file, create one if not, modify the index-url to the pip source you need, the content is as follows:[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Modifying the configuration file in windows
Create a pip directory directly in the user directory, such as: C:\Users\watson\pip, and create a new file pip.ini with the following contents:[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
where index-url is the pip source of your choice