pip安装包或更新时因超时而报错误(raise ReadTimeoutError(self._pool, None, “Read timed out.“) pip._vendor.urllib3.ex

报错原因

想要使用pip,结果出下以下警告:
WARNING: You are using pip version 20.1.1; however, version 20.2.2 is available. You should consider upgrading via the 'D:\Python37\python.exe -m pip install --upgrade pip' command.
本着强迫症的原则,就按它的要求进行python -m pip install --upgrade pip命令用于更新pip,结果引发了一系列错误(节选):
File "D:\Python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 430, in _error_catcher raise ReadTimeoutError(self._pool, None, "Read timed out.") pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
原来是这些源是国外的,访问慢的很,就造成了超时错误。。。。

解决方法

将下载源改为国内的下载源,下载速度飙升,分分钟搞定。
代码格式:

pip install 第三方库名 -i 网址

国内源:

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

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

  3. 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

  4. 华中理工大学:http://pypi.hustunique.com/

  5. 山东理工大学:http://pypi.sdutlinux.org/

  6. 豆瓣:http://pypi.douban.com/simple/

参考

Installing build dependencies ... error error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully.exit code: 2 ╰─> [65 lines of output] Collecting setuptools>=40.8.0 Downloading setuptools-80.9.0-py3-none-any.whl.metadata (6.6 kB) Downloading setuptools-80.9.0-py3-none-any.whl (1.2 MB) ━━━━━━ 0.2/1.2 MB 7.4 kB/s eta 0:02:18 ERROR: Exception: Traceback (most recent call last): File "/home/mse/myenv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher yield File "/home/mse/myenv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 561, in read data = self._fp_read(amt) if not fp_closed else b"" ^^^^^^^^^^^^^^^^^^ File "/home/mse/myenv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read return self._fp.read(amt) if amt is not None else self._fp.read() ^^^^^^^^^^^^^^^^^^ File "/home/mse/myenv/lib/python3.12/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 98, in read data: bytes = self.__fp.read(amt) ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/http/client.py", line 479, in read s = self.fp.read(amt) ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/socket.py", line 707, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/ssl.py", line 1252, in recv_into return self.read(nbytes, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/ssl.py", line 1104, in read return self._sslobj.read(len, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 377, in run requirement_set = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 179, in resolve self.factory.preparer.prepare_linked_requirements_more(reqs) File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 552, in prepare_linked_requirements_more self._complete_partial_requirements( File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 467, in _complete_partial_requirements for link, (filepath, _) in batch_download: File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/network/download.py", line 183, in __call__ for chunk in chunks: File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py", line 53, in _rich_progress_bar for chunk in iterable: File "/home/mse/myenv/lib/python3.12/site-packages/pip/_internal/network/utils.py", line 63, in response_chunks for chunk in response.raw.stream( File "/home/mse/myenv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 622, in stream data = self.read(amt=amt, decode_content=decode_content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mse/myenv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 560, in read with self._error_catcher(): File "/usr/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/home/mse/myenv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 443, in _error_catcher raise ReadTimeoutError(self._pool, None, "Read timed out.") pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully.exit code: 2 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip.
最新发布
06-10
zql10639@zql10639-VMware-Virtual-Platform:~$ tail -n 50 /home/zql10639/.local/state/pipx/log/cmd_2025-04-02_11.30.44_pip_errors.log data: bytes = self.__fp.read(amt) ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/http/client.py", line 479, in read s = self.fp.read(amt) ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/socket.py", line 707, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/ssl.py", line 1252, in recv_into return self.read(nbytes, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/ssl.py", line 1104, in read return self._sslobj.read(len, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 377, in run requirement_set = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 179, in resolve self.factory.preparer.prepare_linked_requirements_more(reqs) File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 552, in prepare_linked_requirements_more self._complete_partial_requirements( File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 467, in _complete_partial_requirements for link, (filepath, _) in batch_download: File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/network/download.py", line 183, in __call__ for chunk in chunks: File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py", line 53, in _rich_progress_bar for chunk in iterable: File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_internal/network/utils.py", line 63, in response_chunks for chunk in response.raw.stream( File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 622, in stream data = self.read(amt=amt, decode_content=decode_content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 560, in read with self._error_catcher(): File "/usr/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/home/zql10639/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 443, in _error_catcher raise ReadTimeoutError(self._pool, None, "Read timed out.") pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值