python install_error ai_generated true

FileNotFoundError:[Errno 2] 没有那个文件或目录:'setup.py' 错误:在获取构建 wheel 所需依赖时构建 'foo' 失败

FileNotFoundError: [Errno 2] No such file or directory: 'setup.py' ERROR: Failed to build 'foo' when getting requirements to build wheel

ID: python/setuptools-no-setup-py

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

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

项目没有 setup.py(仅 pyproject.toml),但某个工具或 pip 调用假定使用旧的 setup.py 入口,或工作目录错误。

English

The project has no setup.py (pyproject.toml-only) but a tool or pip invocation assumes the legacy setup.py entry point, or the working directory is wrong.

generic

解决方案

  1. 92% 成功率
    Add a minimal pyproject.toml with a build backend:
    [build-system]
    requires = ["setuptools>=61"]
    build-backend = "setuptools.build_meta"
    
    [project]
    name = "foo"
    version = "1.0.0"
  2. 85% 成功率
    Confirm you are in the project root:
    ls pyproject.toml setup.py setup.cfg
    pip install .

无效尝试

常见但无效的做法:

  1. 85% 失败

    An empty setup.py makes the build fail later with 'no commands supplied' or metadata errors.

  2. 70% 失败

    Still expects a build backend; if pyproject.toml is missing, there is nothing to build.