You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Action依赖安装报错:已声明matplotlib仍提示缺失

问题解决:安装aesthetic==0.6时提示找不到matplotlib模块

问题原因

aesthetic 0.6的安装脚本(setup.py)在执行构建前置步骤时直接导入了matplotlib,但pip处理requirements.txt的默认流程是:先解析所有包的构建需求,此时matplotlib还未完成安装,因此触发ModuleNotFoundError。

解决方案

方案1:先单独安装matplotlib,再安装完整依赖

修改GitHub Action中的依赖安装步骤,先安装matplotlib,再执行requirements.txt的安装:

- name: Install dependencies
  run: |
    python -m pip install --upgrade pip
    pip install matplotlib
    pip install -r requirements.txt

这样在处理aesthetic的构建需求时,matplotlib已存在于环境中,不会触发找不到模块的错误。

方案2:升级aesthetic到最新版本

检查aesthetic的新版本是否修复了构建时直接导入依赖的问题,若允许升级,可将requirements.txt中的aesthetic==0.6改为aesthetic(或指定更高版本号)。新版本大概率改用了更规范的依赖声明方式(如pyproject.toml),能避免这类构建时的依赖问题。

方案3:禁用pip的构建隔离(谨慎使用)

使用--no-build-isolation参数让pip在当前环境中构建包,而非创建隔离环境,但需确保当前环境已具备所有构建依赖:

- name: Install dependencies
  run: |
    python -m pip install --upgrade pip
    pip install -r requirements.txt --no-build-isolation

此方法可能引发其他依赖冲突,仅在方案1、2不可行时尝试。

内容的提问来源于stack exchange,提问作者JPdL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 17:17:27