Colab安装tflite-model-maker遇磁盘满及版本匹配报错求助
问题描述
- 执行命令
!pip install -q tflite-model-maker安装时,耗时极长且磁盘被占满 - 改用命令
!pip install -q --use-deprecated=legacy-resolver tflite-model-maker时,出现版本匹配错误:ERROR: Could not find a version that satisfies the requirement tflite-support>=0.4.2 (from tflite-model-maker) (from versions: 0.1.0a0.dev3, 0.1.0a0.dev4, 0.1.0a0.dev5, 0.1.0a0, 0.1.0a1) ERROR: No matching distribution found for tflite-support>=0.4.2 (from tflite-model-maker) - 当前使用Colab Python 3.10环境,切换Python版本后执行pip安装会收到root用户警告
解决方法
1. 清理pip缓存,缓解磁盘占用
先清理pip缓存,避免重复下载冗余文件导致磁盘爆满:
!pip cache purge
2. 指定兼容Python 3.10的版本安装
tflite-model-maker部分版本对Python 3.10支持不足,尝试安装适配的0.4.2版本,该版本对应的tflite-support依赖版本匹配:
!pip install -q tflite-model-maker==0.4.2
若仍报错,直接指定依赖版本一起安装:
!pip install -q tflite-model-maker==0.4.2 tflite-support==0.4.2
3. 搭配兼容的TensorFlow版本安装
Colab中先安装与Python 3.10兼容的TensorFlow版本,再安装tflite-model-maker,减少依赖解析混乱:
!pip install -q tensorflow==2.12.0 !pip install -q tflite-model-maker
4. 解决切换Python版本的root警告
Colab默认环境已配置好,手动切换版本易引发权限问题。若必须切换,用pyenv管理版本(无需root权限):
!curl https://pyenv.run | bash %env PATH=/root/.pyenv/bin:/root/.pyenv/shims:$PATH !pyenv install 3.9.16 !pyenv global 3.9.16
安装完成后重新初始化shell:
!exec $SHELL
之后执行pip安装就不会出现root警告。
内容的提问来源于stack exchange,提问作者edibesad
相关产品推荐
相关产品推荐

