第一步:(可忽略直接看第二步解决方案)首先我们看一下Python默认用的是哪个地址的镜像:

              在命令行输入  pip help install 

              找出   -i, --index-url <url> 后面对应的地址就是默认的下载源地址:

第二步:解决方案

             Python提供了pip命令,让开发者很容易安装需要的模块。但是,用pip安装时,好多模块默认去外网下载。这样,***就变得灰常缓慢。 这里我们提供一种解决方案。。该镜像的下载地址。

国内的一些站点:

  • 豆瓣:http://pypi.douban.com/simple/
  • 清华:https://pypi.tuna.tsinghua.edu.cn/simple
  • 阿里云:http://mirrors.aliyun.com/pypi/simple/
  • 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  • 华中理工大学:http://pypi.hustunique.com/
  • 山东理工大学:http://pypi.sdutlinux.org/ 

临时使用方法:

     直接在安装模块的后面加参数:  -i   http://pypi.douban.com/simple/

     例如:安装web模块django ,我们这里指定用豆瓣。。

               pip install django -i http://pypi.douban.com/simple/

永久性使用:

     window环境:

            windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini

            内容如下:

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

      Linux环境:

            修改 ~/.pip/pip.conf  (没有的话创建一个,那个“.”必须有, 代表的是隐藏文件夹)

            内容如下:

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