小工具知识网

当前位置: 首页 > 行业知识 > 解决:ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out

行业知识

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

2026-11-05 01:43:52 来源:互联网转载

解决: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.

        截图如下:

        报错翻译

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

          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

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

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

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

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

        方法五:离线安装

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

        安装命令如下:

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

        今天的分享就到此结束了

        欢迎点赞评论关注三连

上一篇:服务器中怎么开创造环境?

下一篇:impact怎么在服务器通过验证?