pip 下载报“connection to pypi.org time out“

本文详细介绍了如何配置pip镜像源,通过设置镜像源,可以加速Python包的下载和安装过程。步骤包括查找userprofile路径,在其下创建pip文件夹及pip.ini文件,编辑并保存文件内容。此外,还提供了多个国内常用镜像源供选择。

1.配置镜像文件这样就可以直接使用pip的指令来完成包的安装和数据的升级
2.首先在cmd中输入set,查看userprofile的位置,一般就在系统盘(C盘)下面的USER
3.在该目录下面建立一个pip的文件夹
4.在该文件下面建立一个pip.ini的文件
5.在该文件中写入如下内容,然后在保存。

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

国内常用的pip源如下:

阿里云 http://mirrors.aliyun.com/pypi/simple/

豆瓣(douban) http://pypi.douban.com/simple/ 

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

去搜了一下,知道是因为没有指定镜像源的原因。需要在后面加上-i参数然后指定镜像,并且要添加信任(--trusted-host 源地址)

如:

pip install paramiko -i http://mirrors.aliyun.com/pypi/simple/   --trusted-host mirrors.aliyun.com

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001FDB34589A0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/numpy/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001FDB3458AF0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/numpy/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001FDB3458DC0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/numpy/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001FDB3458FD0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/numpy/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001FDB3487340>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/numpy/ ERROR: Could not find a version that satisfies the requirement numpy==1.22.3 (from versions: none) ERROR: No matching distribution found for numpy==1.22.3
06-12
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值