当我们用pip 去安装python包的时候,往往遇到速度慢的问题,其实国内多个高校和企业都建立了python包的镜像:
- 阿里云 http://mirrors.aliyun.com/pypi/simple/
- 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
- 豆瓣(douban) http://pypi.douban.com/simple/
- 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
- 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
Windows下,要在用户目录下(一般是C:\User\xx,xx为你的用户名),新建一个pip文件夹,在pip文件夹里面新建一个pip.ini文件,如下图所示。
[global]
index-url = http://pypi.douban.com/simple
对于http源,还需要添加信任信息
[install]
trusted-host=mirrors.aliyun.com
这样,一个完整的配置文件如下所示:
[global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
OK,现在再用pip 试试,安装包的速度就飞起了!