解决pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool

2023-11-13

解决pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out问题

使用命令安装torch

pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

这时候报错:

pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.

2.分析问题产生原因


(1)大概率是网络问题,也就是阿里云的镜像源提供的网速不足以支撑2个G的torch安装
(2)也许可能版本不匹配,但这一问题我在官方网站复制的命令:torch安装官网提供的命令,应该是问题不大的。

3.解决办法


切换镜像源:
豆瓣:http://pypi.douban.com/simple/
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
山东理工大学:http://pypi.sdutlinux.org/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中科技大学:http://pypi.hustunique.com/
因此命令可以改为:
 

pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple

或者一个一个镜像试过去,总会有效果的!

4.大牛提供的方法

如果你的网速一直很拉闸,上面的方法依然解决不了,那这时可以使用如下的解决方案:

pip --default-timeout=1688 install 库名称 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com 

那在这里可以分别用该方法安装torch和torchvision
也就是使用命令:

pip3 --default-timeout=1688 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

这里的--default-timeout=1688其实意思就是让其检测延迟的时间变长,以防止因为你的网络问题而直接报错

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

解决pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool 的相关文章

随机推荐