一、更换默认安装源

 1、Wndows系统

   在用户文件夹(C:\Users\对应用户目录)下创建pip目录,并在pip目录下创建pip.ini文件(%HOMEPATH%\pip\pip.ini),

文件中添加如下内容:(有空格的地方一定要有空格)

[global]
trusted-host = mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple
extra-index-url=https://pypi.tuna.tsinghua.edu.cn/simple
    http://pypi.douban.com/simple
    http://pypi.mirrors.ustc.edu.cn/simple
[install]
trusted-host = mirrors.aliyun.com
    pypi.tuna.tsinghua.edu.cn
    pypi.douban.com
    pypi.mirrors.ustc.edu.cn

   备注: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] 
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

   3、临时使用:

  pip install -i镜像源地址 <package> 或pip install  <package> -i 镜像源地址

  例如:pip install -i http://mirrors.aliyun.com/pypi/simple/ 包