pip install_error ai_generated true

ERROR: File 'setup.py' not found for editable install of '<package>'. A setup.py or pyproject.toml is required.

ID: pip/editable-install-no-setup-py

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
1Evidence
2023-09-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
pip 21.3+ active
Python 3.7-3.12 active

Root Cause

The package being installed in editable mode (pip install -e .) lacks a setup.py, and the pyproject.toml does not define a valid build backend that supports editable installs (e.g., setuptools or hatchling with the build_editable hook).

generic

中文

以可编辑模式安装的包(pip install -e .)缺少 setup.py,并且 pyproject.toml 没有定义支持可编辑安装的有效构建后端(例如具有 build_editable 钩子的 setuptools 或 hatchling)。

Official Documentation

https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs

Workarounds

  1. 90% success Add a pyproject.toml with a build backend that supports editable installs, e.g., using setuptools: [build-system] requires = ["setuptools>=64"] build-backend = "setuptools.build_meta" Then run pip install -e . again.
    Add a pyproject.toml with a build backend that supports editable installs, e.g., using setuptools:
    [build-system]
    requires = ["setuptools>=64"]
    build-backend = "setuptools.build_meta"
    Then run pip install -e . again.
  2. 85% success If the project uses a modern backend like hatchling, ensure pyproject.toml includes: [build-system] requires = ["hatchling"] build-backend = "hatchling.build" [project] name = "<package>" version = "0.1.0" Then install with pip install -e .
    If the project uses a modern backend like hatchling, ensure pyproject.toml includes:
    [build-system]
    requires = ["hatchling"]
    build-backend = "hatchling.build"
    [project]
    name = "<package>"
    version = "0.1.0"
    Then install with pip install -e .
  3. 70% success Use a symlink manually instead of editable install: ln -s /path/to/package /path/to/site-packages/<package> (Linux/macOS) or mklink /D (Windows). This bypasses pip's editable install mechanism.
    Use a symlink manually instead of editable install: ln -s /path/to/package /path/to/site-packages/<package> (Linux/macOS) or mklink /D (Windows). This bypasses pip's editable install mechanism.

中文步骤

  1. Add a pyproject.toml with a build backend that supports editable installs, e.g., using setuptools:
    [build-system]
    requires = ["setuptools>=64"]
    build-backend = "setuptools.build_meta"
    Then run pip install -e . again.
  2. If the project uses a modern backend like hatchling, ensure pyproject.toml includes:
    [build-system]
    requires = ["hatchling"]
    build-backend = "hatchling.build"
    [project]
    name = "<package>"
    version = "0.1.0"
    Then install with pip install -e .
  3. Use a symlink manually instead of editable install: ln -s /path/to/package /path/to/site-packages/<package> (Linux/macOS) or mklink /D (Windows). This bypasses pip's editable install mechanism.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Without proper package discovery configuration, the editable install will fail or install nothing.

  2. 85% fail

    This does not resolve the missing setup.py; it only disables build isolation.

  3. 60% fail

    Older pip versions may work but are insecure and lack modern features; not a sustainable fix.