Guide | By default, pip uses a foreign mirror, which is very slow when downloading. In this article, we introduce the source of using Tsinghua University in China. |
Domestic mirror source
The address is:
https://pypi.tuna.tsinghua.edu.cn/simple
We can directly use the -i parameter in the pip command to specify the mirror address, for example:
pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
The above command uses the Tsinghua mirror source to install the numpy package.
This kind of command is only useful for the current installation. If you need to modify it globally, you need to modify the configuration file. Linux should be learned like this
In the Linux /Mac os environment, the configuration file location is ~/.pip/pip.conf (create the directory and file if it does not exist):
mkdir ~/.pip
Open the configuration file ~/.pip/pip.conf and modify it as follows:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
View the mirror address:
$ pip3 config list
global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'
install.trusted-host='https://pypi.tuna.tsinghua.edu.cn'
You can see that the image has been successfully modified.
Under Windows, you need to create a pip.ini in the current user directory (C:\Users\xx\pip, xx represents the current user, such as Zhang San) and enter the following content in the pip.ini file:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
Other domestic mirror sources
- University of Science and Technology of China: https://pypi.mirrors.ustc.edu.cn/simple
Douban: http://pypi.douban.com/simple/