ImportPython Error

pip editable install error

ERROR: Project directory is not installable. File 'setup.py' or 'pyproject.toml' not found.

Traceback

terminal
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    # ERROR: File 'setup.py' or 'pyproject.toml' not found
ERROR: Project directory is not installable. File 'setup.py' or 'pyproject.toml' not found.

What causes this error

pip install -e (editable mode) was run in a directory that lacks setup.py, setup.cfg, or pyproject.toml. The directory is not recognized as a Python package.

How to fix it

Create a `pyproject.toml` with the required build system and project metadata. Ensure you are in the correct directory. For modern projects, use `pyproject.toml` with setuptools, hatch, or flit as the build backend.

Code that causes this error

Broken
cd my-project
pip install -e .
# ERROR: File 'setup.py' or 'pyproject.toml' not found

Fixed code

Fixed
# Create pyproject.toml:
# [build-system]
# requires = ["setuptools>=68.0"]
# build-backend = "setuptools.backends._legacy:_Backend"
# [project]
# name = "my-project"
# version = "0.1.0"

pip install -e .

About pip editable install error

This error occurs when running `pip install -e .` (editable/development install) on a directory that is not a valid Python package. An editable install requires either a `setup.py`, `setup.cfg`, or `pyproject.toml` file that defines the package metadata and build system. The editable install creates a link from the Python environment to your source code, so changes to the code take effect immediately without reinstalling.

This error commonly appears when running the install from the wrong directory, when the project has not been set up with proper package configuration, or when migrating from setup.py to pyproject.toml and the new file is incomplete. Modern Python projects should use `pyproject.toml` with a build backend like setuptools, hatch, flit, or PDM as the single source of package configuration.

Common scenarios

1

Installing packages in a different virtual environment than the one in use

2

Circular imports between modules that depend on each other

3

Typos in module or package names in import statements

4

Naming a local file the same as a standard library module

Related errors