If you install many large packages in China, you will find that the speed is very slow. This is because the default installation source of pip is generally abroad, and the speed is usually only tens of K, so you don’t feel it when you install a small package, but it is very slow when you install a large package. Obvious.
1. If you just want to temporarily change the installation source, then use the -i option to temporarily specify the installation source for this installation:
pip install labelme -i https://pypi.tuna.tsinghua.edu.cn/simple
2. If you want to permanently add the domestic mirror installation source
2.1. Use the pip -v config list command to see that the site variable is in the /usr/pip.conf file
sudo pip -v config list
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '/root/.pip/pip.conf'
For variant 'user', will try loading '/root/.config/pip/pip.conf'
For variant 'site', will try loading '/usr/pip.conf'
2.2. Add the following content to the file /usr/pip.conf specified by 'site' in the previous chapter
pip first installs from the source specified by index-url. If the installation package cannot be found in the source specified by index-url, it will install it from the source specified by extra-index-url. Adding trusted-host and ssl_verfy: false can reduce many installation source security verification problems, which will bring a lot of convenience, but of course it may also bring security risks.
[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
extra-index-url = https://pypi.tuna.tsinghua.edu.cn/simple
https://mirrors.aliyun.com/pypi/simple
hppts://pypi.douban.com/simple
[install]
trusted-host=
pypi.tuna.tsinghua.edu.cn
mirrors.aliyun.com
pypi.douban.com
pypi.mirrors.ustc.edu.cn
ssl_verify: false
3. The following are some recommended domestic image sources with fast speed and new installation packages:
name | URL |
---|---|
University of Science and Technology of China | https://pypi.mirrors.ustc.edu.cn/simple/ |
Tsinghua University | https://pypi.tuna.tsinghua.edu.cn/simple/ |
Ali Cloud | https://mirrors.aliyun.com/pypi/simple/ |
watercress | https://pypi.douban.com/simple/ |