pip3 install ryu Collecting ryu Downloading ryu-4.34.tar.gz (1.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 16.2 kB/s eta 0:00:00 Installing build dependencies ... error error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 2 ╰─> [73 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.8/1.2 MB 9.2 kB/s eta 0:00:46 ERROR: Exception: Traceback (most recent call last): File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher yield File "/home/chen/ryu-env/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/chen/ryu-env/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/chen/ryu-env/lib/python3.12/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 98, in read data: bytes = self.__fp.read(amt) ^^^^^^^^^^^^^^^^^^^ File "/home/chen/anaconda3/lib/python3.12/http/client.py", line 479, in read s = self.fp.read(amt) ^^^^^^^^^^^^^^^^^ File "/home/chen/anaconda3/lib/python3.12/socket.py", line 720, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/chen/anaconda3/lib/python3.12/ssl.py", line 1251, in recv_into return self.read(nbytes, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/chen/anaconda3/lib/python3.12/ssl.py", line 1103, 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/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 105, in _run_wrapper status = _inner_run() ^^^^^^^^^^^^ File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run return self.run(options, args) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 67, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 379, in run requirement_set = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "/home/chen/ryu-env/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/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 554, in prepare_linked_requirements_more self._complete_partial_requirements( File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 469, in _complete_partial_requirements for link, (filepath, _) in batch_download: ^^^^^^^^^^^^^^ File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/network/download.py", line 184, in __call__ for chunk in chunks: ^^^^^^ File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py", line 55, in _rich_progress_bar for chunk in iterable: ^^^^^^^^ File "/home/chen/ryu-env/lib/python3.12/site-packages/pip/_internal/network/utils.py", line 65, in response_chunks for chunk in response.raw.stream( ^^^^^^^^^^^^^^^^^^^^ File "/home/chen/ryu-env/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/chen/ryu-env/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py", line 560, in read with self._error_catcher(): ^^^^^^^^^^^^^^^^^^^^^ File "/home/chen/anaconda3/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/home/chen/ryu-env/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.
时间: 2025-06-01 09:12:37 浏览: 18
### 解决 `pip3 install ryu` 过程中出现的 `HTTPSConnectionPool` 读取超时错误
在使用 `pip3` 安装 Ryu 时,如果遇到 `ReadTimeoutError` 或类似问题,通常与网络连接不稳定、镜像源选择不当或依赖项缺失有关。以下是详细的解决方法:
#### 增加超时时间
通过设置更大的超时时间可以避免因网络延迟导致的读取超时错误。使用 `--default-timeout` 参数指定超时时间:
```bash
pip3 install ryu --default-timeout=100
```
此方法适用于网络较慢但稳定的情况[^1]。
#### 使用国内镜像源
国外的 PyPI 源可能由于网络限制导致下载速度慢或失败。切换到国内镜像源可以显著提高安装成功率。例如,使用清华大学的镜像源:
```bash
pip3 install ryu -i https://pypi.tuna.tsinghua.edu.cn/simple
```
此外,还可以配置全局镜像源以减少每次安装时的手动设置:
```bash
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
```
#### 升级 `pip` 和相关工具
旧版本的 `pip` 可能存在兼容性问题,升级到最新版本有助于解决问题:
```bash
pip3 install --upgrade pip setuptools wheel
```
确保 `setuptools` 和 `wheel` 的版本也保持最新,以支持 Ryu 的安装需求[^2]。
#### 清理缓存并重试
有时,缓存中的损坏文件可能导致安装失败。清理缓存后重新尝试安装:
```bash
pip3 cache purge
pip3 install ryu
```
#### 手动编译安装
如果上述方法均无效,可以从源代码手动编译安装 Ryu:
```bash
git clone https://github.com/osrg/ryu.git
cd ryu
python3 setup.py install
```
此方法需要确保系统已安装必要的开发工具和依赖项,例如 `build-essential` 和 `python3-dev`[^3]。
#### 验证安装
安装完成后,可以通过以下命令验证 Ryu 是否成功安装:
```bash
ryu-manager --version
```
#### 注意事项
- 如果仍然遇到 `subprocess-exited-with-error` 错误,请检查错误日志中的具体提示,并根据提示安装缺失的依赖项。
- 确保系统中没有其他版本的 Ryu 冲突。如果存在冲突,可以先卸载旧版本再重新安装:
```bash
pip3 uninstall ryu
pip3 install ryu
```
阅读全文
相关推荐

















