在Google Colab执行!pip install PyDither时遇安装错误的解决求助
在Google Colab中安装PyDither失败的解决方法
问题
在Google Colab执行!pip install PyDither时,触发以下安装错误:
正在检查索引:https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/ 正在收集PyDither 下载PyDither-0.0.1.tar.gz (2.2 kB) 准备元数据(setup.py)...完成 正在收集numpy==1.19.0(来自PyDither) 下载numpy-1.19.0.zip (7.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 93.7 MB/s 预计剩余时间 0:00:00 安装构建依赖...完成 获取构建wheel的需求...完成 准备元数据(pyproject.toml)...完成 已满足依赖:opencv-python在/usr/local/lib/python3.10/dist-packages中(来自PyDither)(4.7.0.72) INFO: pip正在检查多个opencv-python版本,以确定哪个版本与其他需求兼容。这可能需要一些时间。 正在收集opencv-python(来自PyDither) 下载opencv_python-4.7.0.68-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (61.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.8/61.8 MB 9.8 MB/s 预计剩余时间 0:00:00 下载opencv_python-4.6.0.66-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.9/60.9 MB 13.7 MB/s 预计剩余时间 0:00:00 下载opencv_python-4.5.5.64-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.5/60.5 MB 10.1 MB/s 预计剩余时间 0:00:00 下载opencv_python-4.5.5.62-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.4/60.4 MB 13.2 MB/s 预计剩余时间 0:00:00 下载opencv_python-4.5.4.60-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.3/60.3 MB 9.2 MB/s 预计剩余时间 0:00:00 下载opencv_python-4.5.4.58-cp310-cp310-manylinux2014_x86_64.whl (60.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.3/60.3 MB 10.9 MB/s 预计剩余时间 0:00:00 下载opencv-python-4.5.3.56.tar.gz (89.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 MB 7.7 MB/s 预计剩余时间 0:00:00 错误:subprocess-exited-with-error × 用于安装构建依赖的pip子进程未成功运行。 │ 退出代码:1 ╰─> 查看上方输出。 注意:此错误源自子进程,可能与pip无关。 安装构建依赖...错误 错误:subprocess-exited-with-error × 用于安装构建依赖的pip子进程未成功运行。 │ 退出代码:1 ╰─> 查看上方输出。 注意:此错误源自子进程,可能与pip无关。
原因
PyDither的PyPI包指定了numpy==1.19.0,但该版本不兼容Colab默认的Python 3.10,同时pip在尝试匹配opencv-python版本时触发了构建依赖安装失败。
解决方法
方法1:忽略numpy版本强制安装
执行以下命令,跳过numpy的版本检查,直接使用Colab已有的numpy版本安装PyDither:
!pip install PyDither --ignore-installed numpy
方法2:安装兼容的numpy版本后再装PyDither
先安装支持Python 3.10的旧版numpy,再安装PyDither:
!pip install numpy==1.21.6 !pip install PyDither
方法3:手动安装源码版本
如果前两种方法无效,直接克隆PyDither仓库并本地安装:
!git clone https://github.com/ultralytics/PyDither.git %cd PyDither !pip install -e .
内容的提问来源于stack exchange,提问作者zell
相关产品推荐
相关产品推荐

