解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out

2024-06-04 9983阅读

解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out

文章目录

  • 解决:ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out
    • 背景
    • 报错问题
    • 报错翻译
    • 报错原因
    • 解决方法
      • 方法一:更换下载源
      • 方法二:设置超时时间
      • 方法三:换源+设置超时
      • 方法四:检查或更换网络环境
      • 方法五:离线安装
      • 今天的分享就到此结束了

        背景

        使用之前的代码时,报错:

        raise ReadTimeoutError(self._pool, None, ‘Read timed out.’)

        ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.

        报错问题

          raise ReadTimeoutError(self._pool, None, 'Read timed out.')
        ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
        

        截图如下:

        解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out 第1张

        报错翻译

        主要报错信息内容翻译如下所示:

          raise ReadTimeoutError(self._pool, None, 'Read timed out.')
        ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
        

        翻译:

          引发 ReadTimeoutError(self._pool, None, '读取超时。
        ReadTimeoutError:HTTPSConnectionPool(host='files.pythonhosted.org', port=443):读取超时。
        

        报错原因

        经过查阅资料,发现是在安装codecs,theano等模块时,经常出现这个问题。主要原因是网络连通性不好,网络连接不稳定(网络问题)。

        小伙伴们按下面的解决方法即可解决!!!

        解决方法

        要解决这个错误,有如下几种方法:

        方法一:更换下载源

        修改默认的pip安装源请参考:修改默认的pip安装源(修改默认的PyPI安装源)

        临时使用常用的国内源下载,例如:

        清华源:

        pip install xxxx -i https://pypi.tuna.tsinghua.edu.cn/simple
        

        豆瓣源:

        pip install xxxx -i https://pypi.douban.com/simple
        

        附,国内各大源列表:

        名称地址
        阿里https://mirrors.aliyun.com/pypi/simple
        豆瓣http://pypi.douban.com/simple/
        清华大学https://pypi.tuna.tsinghua.edu.cn/simple
        中国科学技术大学https://pypi.mirrors.ustc.edu.cn/simple
        华中理工大学http://pypi.hustunique.com/simple
        山东理工大学http://pypi.sdutlinux.org/simple
        网易https://mirrors.163.com/pypi/simple/
        腾讯https://mirrors.cloud.tencent.com/pypi/simple

        方法二:设置超时时间

        使用超时时间设置,例如:

        pip --default-timeout=500 install xxxx 
        pip --default-timeout=500 install -U pip xxxx
        

        注意,等号后面的超时时间值可以调整。

        方法三:换源+设置超时

        同时更换国内源 + 设置超时时间,(就是有时仍慢了点,但仍有可能传输中断):

        pip --default-timeout=500 install xxxx -i https://pypi.tuna.tsinghua.edu.cn/simple
        

        或者

        pip --default-timeout=500 install xxxx -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
        

        注意:如果还是超时了,可以设置更大的超时时间数

        解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out 第2张

        方法四:检查或更换网络环境

        检查下是否开启代理或者***,将其关闭再使用国内镜像进行尝试看看是否可以解决,我这边有过代理开启导致网络太慢而报错的。

        或者干脆换一个网络条件更好的网络环境。

        方法五:离线安装

        当网络条件太差并且没有别的选择时,而上述方法都行不通,就只能手动下载离线安装包,进行离线安装了。以catboost为例。

        解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out 第3张

        解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out 第4张

        安装命令如下:

        pip install catboost-0.24.2-cp36-none-win_amd64.whl

        今天的分享就到此结束了

        欢迎点赞评论关注三连

        解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out 第5张


    免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

    目录[+]