一、更换默认安装源
1、Wndows系统
在用户文件夹(C:Users对应用户目录)下创建pip目录,并在pip目录下创建pip.in文件(%HOMEPATH%pippip.ini),文件中添加如下内容:
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
备注:index-url即源地址,trusted-host为源地址的域名,由于国内的源镜像都为使用https协议,所以如果不添加信任域就会报:
This repository located at mirrors.aliyun.com is not a trusted host, if this repository is available via HTTPS it is recommend to use HTTPS instead, otherwise you may silence this warning with ‘–trusted-host mirrors.aliyun.com’.
DEPRECATION: Implicitly allowing locations which are not hosted at a secure origin is deprecated and will require the use of –trusted-host in the future.
2、Linux系统
linux的文件在~/.pip/pip.conf
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
3、手动指定:
pip install -i http://<mirror>/simple <package> 或pip install <package> -i http://<mirror>/simple
例如:pip install -i http://mirrors.aliyun.com/pypi/simple/