错误:找不到用于构建项目的后端。该项目使用的构建后端未安装。后端:'setuptools.build_meta'
ERROR: Could not find a backend for building the project. The project uses a build backend that is not installed. Backend: 'setuptools.build_meta'
ID: pip/pep-517-build-backend-requires
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 23.0 | active | — | — | — |
| pip 23.1 | active | — | — | — |
| pip 23.2 | active | — | — | — |
| setuptools 67.0 | active | — | — | — |
| setuptools 68.0 | active | — | — | — |
根因分析
项目的 pyproject.toml 指定了构建后端(如 setuptools.build_meta),但当前环境中未安装该后端,导致 pip 在包安装前失败。
English
The project's pyproject.toml specifies a build backend (e.g., setuptools.build_meta) that is not installed in the current environment, causing pip to fail before any package installation.
官方文档
https://pip.pypa.io/en/stable/reference/build-system/解决方案
-
Install the missing backend explicitly: pip install setuptools wheel
-
If using a different backend (e.g., flit_core): pip install flit_core
-
Create a virtual environment and reinstall: python -m venv venv && source venv/bin/activate && pip install --upgrade pip setuptools wheel
无效尝试
常见但无效的做法:
-
90% 失败
This bypasses build isolation but still requires the backend to be installed; if setuptools is missing, it still fails.
-
100% 失败
This flag ignores Python version constraints, not build backend requirements; irrelevant to the error.
-
70% 失败
Removing pyproject.toml may cause pip to fall back to legacy build, but if setup.py is also missing or incompatible, it fails; also breaks modern packaging.