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

安装matplotlib==3.7.2时wheel构建失败,求setuptools_scm错误解决办法

问题描述

尝试安装matplotlib==3.7.2时,wheel构建失败,核心报错为:

LookupError: pyproject.toml does not contain a tool.setuptools_scm section

详细错误日志如下:

22:46:20 #7 1522.2 Building wheel for matplotlib (pyproject.toml): started
22:46:37 #7 1537.8 Building wheel for matplotlib (pyproject.toml): finished with status 'error'
22:46:37 #7 1538.3 error: subprocess-exited-with-error
22:46:37 #7 1538.3
22:46:37 #7 1538.3 × Building wheel for matplotlib (pyproject.toml) did not run successfully.
22:46:37 #7 1538.3 │ exit code: 1
22:46:37 #7 1538.3 ╰─> [866 lines of output]
22:46:37 #7 1538.3 /tmp/pip-build-env-bzm732jz/overlay/lib/python3.11/site-packages/setuptools/dist.py:806: SetuptoolsDeprecationWarning: The namespace_packages parameter is deprecated.
22:46:37 #7 1538.3 !!
22:46:37 #7 1538.3 ********************************************************************************
22:46:37 #7 1538.3 Please replace its usage with implicit namespaces (PEP 420).
22:46:37 #7 1538.3 See relevant documentation for details.
22:46:37 #7 1538.3 ********************************************************************************
22:46:37 #7 1538.3 !!
22:46:37 #7 1538.3 ep.load()(self, ep.name, value)
22:46:37 #7 1538.3 WARNING setuptools_scm.pyproject_reading toml section missing 'pyproject.toml does not contain a tool.setuptools_scm section'
22:46:37 #7 1538.3 Traceback (most recent call last):
22:46:37 #7 1538.3 File "/tmp/pip-build-env-bzm732jz/overlay/lib/python3.11/site-packages/setuptools_scm/_integration/pyproject_reading.py", line 36, in read_pyproject
22:46:37 #7 1538.3 section = defn.get("tool", {})[tool_name]
22:46:37 #7 1538.3 ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
22:46:37 #7 1538.3 KeyError: 'setuptools_scm'
22:46:37 #7 1538.3 /tmp/pip-build-env-bzm732jz/overlay/lib/python3.11/site-packages/setuptools_scm/git.py:310: UserWarning: git archive did not support describe output
22:46:37 #7 1538.3 warnings.warn("git archive did not support describe output")
22:46:37 #7 1538.3 /tmp/pip-build-env-bzm732jz/overlay/lib/python3.11/site-packages/setuptools_scm/git.py:328: UserWarning: unprocessed git archival found (no export subst applied)
22:46:37 #7 1538.3 warnings.warn("unprocessed git archival found (no export subst applied)")
22:46:37 #7 1538.3 /tmp/pip-build-env-bzm732jz/overlay/lib/python3.11/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
22:46:37 #7 1538.3 !!
22:46:37 #7 1538.3 ********************************************************************************
22:46:37 #7 1538.3 Please consider removing the following classifiers in favor of a SPDX license expression:
22:46:37 #7 1538.3 License :: OSI Approved :: Python Software Foundation License
22:46:37 #7 1538.3 See relevant documentation for details.
22:46:37 #7 1538.3 ********************************************************************************
22:46:37 #7 1538.3 !!
22:46:37 #7 1538.3 self._finalize_license_expression()
22:46:37 #7 1538.3
22:46:37 #7 1538.3 Edit mplsetup.cfg to change the build options; suppress output with --quiet.
22:46:37 #7 1538.3
22:46:37 #7 1538.3 BUILDING MATPLOTLIB
22:46:37 #7 1538.3 python: yes [3.11.9 (main, Apr 2 2025, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-5)]]
22:46:37 #7 1538.3 platform: yes [linux]
22:46:37 #7 1538.3 tests: no [skipping due to configuration]
22:46:37 #7 1538.3 macosx: no [Mac OS-X only]

该问题存在相关开放议题,求临时解决办法。

临时解决办法

1. 指定兼容版本的setuptools-scm

错误源于新版setuptools-scm对pyproject.toml的校验更严格,而matplotlib 3.7.2未适配。安装时强制指定旧版本即可:

pip install matplotlib==3.7.2 setuptools-scm<7.0

2. 使用预编译wheel包

直接用PyPI上的预编译包,跳过本地构建步骤:

pip install --only-binary :all: matplotlib==3.7.2

3. 禁用setuptools-scm版本检测

通过环境变量让setuptools-scm直接使用指定版本号,不再读取pyproject.toml或git信息:

SETUPTOOLS_SCM_PRETEND_VERSION=3.7.2 pip install matplotlib==3.7.2

4. 手动修改源码的pyproject.toml(仅本地构建场景)

若必须从源码构建,下载matplotlib 3.7.2源码包后,在pyproject.toml中添加以下内容:

[tool.setuptools_scm]

再执行本地安装:

pip install .

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 06:39:50