pip安装模块速度慢(国内镜像源)

6:pip安装模块速度慢

经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的烦恼。

01:国内源

新版ubuntu要求使用https源,要注意。
清华: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/ 
豆瓣:http://pypi.douban.com/simple/
这是清华大学的pip源,它是官网pypi的镜像,每隔5分钟同步一次,
地址为 https://pypi.tuna.tsinghua.edu.cn/simple

02:使用方法

1:临时使用:

# 可以在使用pip的时候加参数
-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:

#这样就会从清华这边的镜像去安装gevent库。
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent

2:永久修改,pip修改配置文件:

Linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:

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

windows下,直接在user目录中创建一个pip目录,如:C:Usersxxpip,新建文件pip.ini,内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
原文地址:https://www.cnblogs.com/liuys635/p/12813937.html