错误:找不到满足 pyproject.toml 构建系统要求中 setuptools>=40.8.0 的版本
ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from pyproject.toml build-system.requires)
ID: pip/pep-517-build-backend-missing
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 23.0 | active | — | — | — |
| pip 24.1 | active | — | — | — |
| pip 24.3 | active | — | — | — |
根因分析
项目的 pyproject.toml 指定了一个构建后端(例如 setuptools)及其版本约束,但 pip 在可用索引中找不到该后端的任何版本,通常是因为索引不可达或包名拼写错误。
English
The project's pyproject.toml specifies a build backend (e.g., setuptools) with a version constraint, but pip cannot find any version of that backend in the available indexes, often because the index is unreachable or the package name is misspelled.
官方文档
https://pip.pypa.io/en/stable/topics/build-system/解决方案
-
确保索引 URL 可访问且包含所需后端:pip install --index-url https://pypi.org/simple setuptools>=40.8.0
-
在 pyproject.toml 中指定自定义索引或通过 PIP_EXTRA_INDEX_URL 指定额外索引 URL,如果后端托管在私有索引上。
-
如果项目简单,降级 pip 以支持传统的 setup.py 安装:pip install pip==21.3.1 && pip install <package>
无效尝试
常见但无效的做法:
-
Install the build backend manually before running pip install
70% 失败
pip checks the build backend requirement during the build process and still fails because it tries to satisfy the constraint from pyproject.toml, even if the package is already installed.
-
Remove the build-system section from pyproject.toml entirely
50% 失败
This may cause pip to fall back to legacy setup.py, but if the project relies on PEP 517 features, the build may fail with a different error like 'Missing build backend'.