在Kaggle Notebook安装tflite-model-maker遇依赖冲突求解决
在Kaggle Notebook安装tflite-model-maker的依赖冲突解决办法
问题描述
在Kaggle Notebook中调用tflite-model-maker包时出现module not found错误,执行安装命令!pip install tflite_model_maker后触发以下依赖冲突:
ERROR: Cannot install tflite-model-maker==0.1.2, tflite-model-maker==0.2.0, tflite-model-maker==0.2.1, tflite-model-maker==0.2.2, tflite-model-maker==0.2.3, tflite-model-maker==0.2.4, tflite-model-maker==0.2.5, tflite-model-maker==0.3.3, tflite-model-maker==0.3.4, tflite-model-maker==0.4.0, tflite-model-maker==0.4.1 and tflite-model-maker==0.4.2 because these package versions have conflicting dependencies. The conflict is caused by: tflite-model-maker 0.4.2 depends on numba==0.53 tflite-model-maker 0.4.1 depends on numba==0.53 tflite-model-maker 0.4.0 depends on numba==0.53 tflite-model-maker 0.3.4 depends on numba==0.53 tflite-model-maker 0.3.3 depends on numba==0.53 tflite-model-maker 0.2.5 depends on tflite-support==0.1.0rc4 tflite-model-maker 0.2.4 depends on tflite-support==0.1.0rc4 tflite-model-maker 0.2.3 depends on tflite-support==0.1.0rc3.dev2 tflite-model-maker 0.2.2 depends on tflite-support==0.1.0rc3.dev2 tflite-model-maker 0.2.1 depends on tflite-support==0.1.0rc3.dev2 tflite-model-maker 0.2.0 depends on tflite-support==0.1.0rc3.dev2 tflite-model-maker 0.1.2 depends on tflite-support==0.1.0rc3.dev2 To fix this you could try to: 1. loosen the range of package versions you've specified 2. remove package versions to allow pip attempt to solve the dependency conflict
一、执行提示中解决选项的具体操作
选项1:放宽包版本范围
指定特定版本的tflite-model-maker,并用旧版依赖解析器让pip灵活匹配依赖版本:
!pip install tflite-model-maker==0.4.2 --use-deprecated=legacy-resolver
该命令允许pip在合理范围内调整依赖包版本,避免严格版本匹配导致的冲突。
选项2:移除指定包版本,让pip自动解决冲突
先清理pip缓存,再重新执行安装命令,让pip自动选择兼容的版本组合:
!pip cache purge !pip install tflite-model-maker --upgrade
如果仍有冲突,可先卸载冲突的依赖包(比如numba),再重新安装:
!pip uninstall numba -y !pip install tflite-model-maker
二、更直接的解决办法
方法1:匹配依赖版本后安装
根据错误信息,tflite-model-maker 0.4.x依赖numba==0.53,先安装指定版本的numba,再安装对应版本的tflite-model-maker:
!pip install numba==0.53 -y !pip install tflite-model-maker==0.4.2
若需使用旧版本,可选择依赖tflite-support==0.1.0rc4的0.2.5版本:
!pip install tflite-model-maker==0.2.5
方法2:强制安装并覆盖冲突依赖
如果不需要保留现有冲突包的版本,可直接强制安装tflite-model-maker并覆盖冲突依赖:
!pip install tflite-model-maker --ignore-installed numba
该命令会忽略当前已安装的numba版本,安装tflite-model-maker所需的numba==0.53版本。
内容的提问来源于stack exchange,提问作者Sazzad Hissain Khan
相关产品推荐
相关产品推荐

