Python- 解决PIP下载安装速度慢

2,204 阅读1分钟

问题描述:

对于Python开发用户来讲,pip安装软件包是家常便饭。但国外的源下载速度实在太慢,浪费时间。而且经常出现下载后安装出错问题。

解决方法

所以把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成功率。

临时使用:

可以在使用pip的时候加参数-i pypi.tuna.tsinghua.edu.cn/simple 例如:pip install -i pypi.tuna.tsinghua.edu.cn/simple numpy,这样就会从清华这边的镜像去安装numpy库。

永久修改:

Linux系统

创建文件:~/.pip/pip.conf (文件夹要加“.”,表示是隐藏文件夹) 内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]
trusted-host=mirrors.aliyun.com

windows系统

直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。
或者不更换安装源,试试笨方法:pip --default-timeout=1000 install -u xxx (xxx为你要安装的包名)

原网页:www.cnblogs.com/microman/p/…