错误:找不到用于构建项目的后端。该项目使用的构建后端未安装。
ERROR: Could not find a backend for building the project. The project uses a build backend that is not installed.
ID: pip/pep-517-backend-not-found
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 21.3+ | active | — | — | — |
| Python 3.9-3.12 | active | — | — | — |
根因分析
pyproject.toml 指定了一个构建后端(例如 flit_core、poetry-core、mesonpy),但在构建环境中不可用,通常是因为它没有被列为 build-system.requires 依赖。
English
The pyproject.toml specifies a build backend (e.g., flit_core, poetry-core, mesonpy) that is not available in the build environment, often because it's not listed as a build-system.requires dependency.
官方文档
https://pip.pypa.io/en/stable/topics/build-system/解决方案
-
Add the missing backend to pyproject.toml under [build-system] requires: [build-system] requires = ["flit_core>=3.2"] build-backend = "flit_core.buildapi" Then re-run pip install.
-
Install the package without build isolation: pip install --no-build-isolation <package>. Ensure the backend is pre-installed in the environment.
-
Upgrade pip to the latest version: python -m pip install --upgrade pip, which may improve backend detection.
无效尝试
常见但无效的做法:
-
85% 失败
Pip's build isolation ignores the global environment; the backend must be declared in pyproject.toml's build-system.requires.
-
70% 失败
Modern packages may not include setup.py; removing pyproject.toml can break the build entirely.
-
60% 失败
This can cause version conflicts or missing dependencies, and is discouraged by pip maintainers.