pip安装Python包时下载速度慢


1. 错误状态

pip或者pip3默认的国外源下载速度实在太慢,浪费时间
时间一长还会出现超时报错,有点炸裂


2. 临时解决办法

安装时在命令里加一个参数 -i,然后在 i 后面加国内镜像地址,再接包

有以下几种国内的镜像源:
清华源: https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云: http://mirrors.aliyun.com/pypi/simple/
中科大: https://pypi.mirrors.ustc.edu.cn/simple/

如 Python3 选用的清华源安装 opencv-contrib-python

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python

在这里插入图片描述
这速度还行吧!


3. 永久解决办法


3.1. linux

修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

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

在这里插入图片描述


3.2. windows

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

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

谢谢

发布了242 篇原创文章 · 获赞 327 · 访问量 305万+

猜你喜欢

转载自blog.csdn.net/qq_32618327/article/details/104497323