Using Domestic Mirror Sources for pip
Category Programming Technology
By default, pip uses an overseas mirror, which is very slow when downloading. In this article, we introduce the use of the domestic source from Tsinghua University, with the address being:
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 installs the numpy package using the Tsinghua mirror source.
This only works for the current installation command. If you need to modify it globally, you need to modify the configuration file.
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
Check 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 mirror has been successfully modified.
On Windows, you need to create a pip.ini in the current user directory (C:\Users\xx\pip, where 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/
Alibaba Cloud: http://mirrors.aliyun.com/pypi/simple/
** Click to Share Notes
-
-
-