python install_error ai_generated true

错误:[Errno 2] 没有那个文件或目录:'setup.py' 错误:为某些基于 pyproject.toml 的项目(foo)构建可安装 wheel 失败

error: [Errno 2] No such file or directory: 'setup.py' ERROR: Failed to build installable wheels for some pyproject.toml based projects (foo)

ID: python/pip-egg-info-failed-setup-py

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2024-07-02首次发现

版本兼容性

版本状态引入弃用备注
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

构建后端需要 setup.py(旧式 setuptools),但包只有 pyproject.toml,或者构建后端被错误配置为使用 setuptools.build_meta:__legacy__。

English

A build backend expects setup.py (legacy setuptools) but the package only has pyproject.toml, or the build backend is misconfigured to use setuptools.build_meta:__legacy__.

generic

解决方案

  1. 90% 成功率
    Fix the build-system table in pyproject.toml:
      [build-system]
      requires = ["setuptools>=61", "wheel"]
      build-backend = "setuptools.build_meta"
    (Not __legacy__, which requires setup.py.)
  2. 85% 成功率
    If you maintain the package, switch to a modern backend (hatchling, poetry-core, flit) that does not need setup.py.

无效尝试

常见但无效的做法:

  1. 80% 失败

    An empty setup.py does not declare metadata; the build produces an unusable package.

  2. 70% 失败

    Isolation is not the issue; the backend cannot find the file it expects.