pip安装模块报错ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org‘, port=443): Read timed

简介: pip安装模块报错ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org‘, port=443): Read timed

今天在安装python模块时提示ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out
具体报错如下:

[root@0018 /]# pip install pygame
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pygame
  Downloading pygame-2.0.3-cp27-cp27mu-manylinux_2_5_x86_64.manylinux1_x86_64.whl (13.3 MB)
     |███████████▊                    | 4.9 MB 8.0 kB/s eta 0:17:40ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
    return func(self, options, args)
  File "/usr/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 321, in run
    reqs, check_supported_wheels=not options.target_dir
  File "/usr/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 180, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/usr/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 385, in _resolve_one
    dist = self._get_dist_for(req_to_install)
  File "/usr/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 337, in _get_dist_for
    dist = self.preparer.prepare_linked_requirement(req)
  File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 480, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 505, in _prepare_linked_requirement
    self.download_dir, hashes,
  File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 257, in unpack_url
    hashes=hashes,
  File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 130, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "/usr/lib/python2.7/site-packages/pip/_internal/network/download.py", line 163, in __call__
    for chunk in chunks:
  File "/usr/lib/python2.7/site-packages/pip/_internal/cli/progress_bars.py", line 168, in iter
    for x in it:
  File "/usr/lib/python2.7/site-packages/pip/_internal/network/utils.py", line 88, in response_chunks
    decode_content=False,
  File "/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 451, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

处理方法pip --default-timeout=100 install -U pygame

这使用pip安装超时,绝大多数原因是pip源在外国,所以国内使用,网络就算稳定,也有一定超时。--default-timeout即增大延时时间。或者更换PIP源,目前常用的有以下几种:
阿里云 http: //mirrors.aliyun.com/pypi/simple/
中国科技大学 https: //pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http: //pypi.douban.com/simple/
清华大学 https: //pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http: //pypi.mirrors.ustc.edu.cn/simple/
临时解决:pip install requests -i https:// pypi.tuna.tsinghua.edu.cn/simple

结果

[root@0018 /]# pip --default-timeout=100 install -U pygame
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pygame
  Downloading pygame-2.0.3-cp27-cp27mu-manylinux_2_5_x86_64.manylinux1_x86_64.whl (13.3 MB)
     |████████████████████████████████| 13.3 MB 22 kB/s 
Installing collected packages: pygame
Successfully installed pygame-2.0.3
相关文章
|
2月前
|
Python
pip批量安装Python库 requirement.txt 离线环境无互联网环境下pip安装Python库
pip批量安装Python库 requirement.txt 离线环境无互联网环境下pip安装Python库
155 3
|
2月前
|
机器学习/深度学习 缓存 Linux
python环境学习:pip介绍,pip 和 conda的区别和联系。哪个更好使用?pip创建虚拟环境并解释venv模块,pip的常用命令,conda的常用命令。
本文介绍了Python的包管理工具pip和环境管理器conda的区别与联系。pip主要用于安装和管理Python包,而conda不仅管理Python包,还能管理其他语言的包,并提供强大的环境管理功能。文章还讨论了pip创建虚拟环境的方法,以及pip和conda的常用命令。作者推荐使用conda安装科学计算和数据分析包,而pip则用于安装无法通过conda获取的包。
139 0
|
2月前
|
自然语言处理 搜索推荐 程序员
【Python】如何使用pip,安装第三方库和生成二维码、操作Excel
【Python】如何使用pip,安装第三方库和生成二维码、操作Excel
64 0
|
3月前
|
机器学习/深度学习 Linux 开发者
Python必备工具:pip的安装与管理
Python必备工具:pip的安装与管理
186 0
|
3月前
|
Linux Shell Python
centos执行pip3 install etcd3报错
centos执行pip3 install etcd3报错
|
3月前
|
缓存 Python
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-npf9报错
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-npf9报错
|
4月前
pip安装iterstrat.ml_stratifiers import MultilabelStratifiedKFold, MultilabelStratifiedShuffleSplit
文章介绍了如何使用iterative-stratification库进行多标签多分类的K折交叉验证,包括安装方法和示例代码。
70 1
|
5月前
|
Web App开发 测试技术 Shell
确保您已经安装了Selenium和ChromeDriver。您可以使用pip来安装Selenium:
确保您已经安装了Selenium和ChromeDriver。您可以使用pip来安装Selenium:
|
5月前
|
SQL Python
你需要在你的系统上安装`sqlmap`。这通常可以通过下载其源代码并编译,或者使用包管理器(如`apt`、`yum`或`pip`,但请注意,`pip`通常不直接提供`sqlmap`)来完成。
你需要在你的系统上安装`sqlmap`。这通常可以通过下载其源代码并编译,或者使用包管理器(如`apt`、`yum`或`pip`,但请注意,`pip`通常不直接提供`sqlmap`)来完成。
|
5月前
|
开发框架 机器人 .NET
我们需要安装`pybullet`模块,这可以通过pip来完成:
我们需要安装`pybullet`模块,这可以通过pip来完成:

热门文章

最新文章

下一篇
DataWorks