Google Colab脚本Setup1阶段安装报错及依赖冲突求助
问题描述
执行某Colab脚本的Setup1步骤时遇到以下问题:
1. pyworld-0.3.0安装失败
安装pyworld-0.3.0时,构建依赖的pip子进程执行失败,报错信息如下:
Downloading pyworld-0.3.0.tar.gz (212 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 212.0/212.0 kB 12.5 MB/s eta 0:00:00 error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. Installing build dependencies ... error error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/, https://download.pytorch.org/whl/cu116
2. 多组依赖冲突
PyTorch系列依赖冲突
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. torchvision 0.15.1+cu118 requires torch==2.0.0, but you have torch 1.13.1+cu116 which is incompatible. torchtext 0.15.1 requires torch==2.0.0, but you have torch 1.13.1+cu116 which is incompatible. torchdata 0.6.0 requires torch==2.0.0, but you have torch 1.13.1+cu116 which is incompatible. torchaudio 2.0.1+cu118 requires torch==2.0.0, but you have torch 1.13.1+cu116 which is incompatible.
Protobuf依赖冲突
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tensorflow-metadata 1.13.1 requires protobuf<5,>=3.20.3, but you have protobuf 3.19.6 which is incompatible. onnx 1.13.1 requires protobuf<4,>=3.20.2, but you have protobuf 3.19.6 which is incompatible.
已尝试但无效的命令
!pip install torch==2.0 !pip install protobuf=3.20.2
解决方案
1. 解决pyworld安装失败
pyworld源码安装需要编译环境,先在Colab中安装编译工具,再用预编译包安装:
!apt-get install -y gcc g++ python3-dev !pip install pyworld --only-binary :all:
2. 修复PyTorch依赖冲突
Colab默认带PyTorch 2.0系列,脚本安装的1.13.1导致冲突,统一安装配套版本:
!pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 torchtext==0.15.1 torchdata==0.6.0 --force-reinstall
3. 修复Protobuf依赖冲突
升级到符合所有依赖要求的版本:
!pip install protobuf==3.20.3 --force-reinstall
4. 一键执行全部修复
把上述命令合并,避免分步操作的问题:
!apt-get install -y gcc g++ python3-dev !pip install pyworld --only-binary :all: !pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 torchtext==0.15.1 torchdata==0.6.0 protobuf==3.20.3 --force-reinstall
内容的提问来源于stack exchange,提问作者Alёna
相关产品推荐
相关产品推荐

