错误:由于 BuildBackendException 无法安装软件包:后端 'setuptools.build_meta' 不可用。该项目需要以下构建依赖项:wheel, setuptools>=61.0。请检查这些依赖项是否已安装并在构建环境中可用。
ERROR: Could not install packages due to a BuildBackendException: Backend 'setuptools.build_meta' is not available. The project requires the following build dependencies: wheel, setuptools>=61.0. Check that these are installed and available in the build environment.
ID: pip/pep-517-backend-requires-missing-dependency
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 23.1 | active | — | — | — |
| pip 23.3 | active | — | — | — |
| pip 24.0 | active | — | — | — |
| setuptools 68.0 | active | — | — | — |
根因分析
pyproject.toml 中指定的构建系统(requires)列出的依赖项未安装在 pip 构建环境中,通常是因为使用了 --no-build-isolation 或构建环境缺少这些软件包。
English
The build system specified in pyproject.toml (requires) lists dependencies that are not installed in the pip build environment, often because --no-build-isolation is used or the build environment lacks those packages.
官方文档
https://pip.pypa.io/en/stable/reference/build-system/解决方案
-
确保构建隔离已启用(默认),pip 将自动在隔离环境中安装所需的构建依赖项。如果必须使用 --no-build-isolation,请预先安装确切的所需版本:pip install 'setuptools>=61.0' wheel
-
将 pip 升级到最新版本,以确保其正确处理 PEP 517/518 构建要求:pip install --upgrade pip
-
手动创建具有所需依赖项的构建环境,然后在激活该环境后使用 pip install --no-build-isolation ./package-dir 安装软件包。
无效尝试
常见但无效的做法:
-
Installing the missing build dependencies globally with pip install setuptools wheel
90% 失败
If pip is using build isolation (default), it creates a temporary build environment that does not inherit global packages; the global install has no effect.
-
Adding --no-build-isolation without ensuring the build environment has the correct versions
70% 失败
The global environment may have older versions of setuptools that do not satisfy the >=61.0 requirement.
-
Deleting pyproject.toml to force legacy setup.py install
85% 失败
Modern packages may not have a setup.py, and pip will refuse to install without a build backend.