Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

pip install says the directory is not installable

ErrorERROR: Directory is not installable. Neither 'setup.py' nor 'pyproject.toml' found

Short answer

pip treats a folder argument as a Python project and needs a pyproject.toml or setup.py inside it. The error means that file is not in the folder you named. Check the path and the working directory first, then add a minimal pyproject.toml, or use pip install -r requirements.txt if you only wanted dependencies.

  • Applies to pip 25, Python 3.12, Docker
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the folder pip was pointed at, from the same place the failing command runs. In Docker, run the ls inside the build.

    pwd
    ls -la
    ls pyproject.toml setup.py
  2. 2Match what you see, then jump to its fix

    1. 1The folder has a requirements.txt and no pyproject.toml, and the command is pip install .You wanted to install dependencies, not the folder as a packageFix
    2. 2ls shows the folder is empty or holds only parts of the project; typical in a Dockerfile where pip runs before COPYThe command runs in the wrong folder or the files were never copiedFix
    3. 3The folder holds your code but neither pyproject.toml nor setup.pyThe project is a package but has no build metadataFix

What does the error look like?

  • ERROR: Directory is not installable. Neither 'setup.py' nor 'pyproject.toml' found
  • pip install . fails in a Dockerfile or CI job

Cause 1 of 3

You wanted to install dependencies, not the folder as a package

1Check

pip accepts a local directory only if it holds pyproject.toml or setup.py. A list of dependencies is installed with -r.

ls requirements.txt

2Fix

Install from the requirements file.

python -m pip install -r requirements.txt

3Verify

pip resolves and installs the listed packages.

python -m pip list

Confirmed by pip.pypa.io

Did this fix it?

Cause 2 of 3

The command runs in the wrong folder or the files were never copied

1Check

Print the directory inside the failing environment. In Docker, the WORKDIR and the COPY lines decide what pip sees.

# add this line before the pip line in the Dockerfile
RUN pwd && ls -la

2Fix

Copy the project files before pip install and run pip from the folder that holds pyproject.toml.

WORKDIR /app
COPY pyproject.toml ./
COPY src ./src
RUN python -m pip install .

3Verify

The build passes the pip step.

docker build -t test .

Confirmed by pip.pypa.io

Did this fix it?

Cause 3 of 3

The project is a package but has no build metadata

1Check

pip asks the build backend for the project's metadata. With no pyproject.toml there is no backend to ask.

ls pyproject.toml setup.py

2Fix

Add a minimal pyproject.toml with a build backend and the project name and version.

[build-system]
requires = ["hatchling >= 1.26"]
build-backend = "hatchling.build"

[project]
name = "my-app"
version = "0.1.0"

3Verify

pip builds and installs the project.

python -m pip install .

Confirmed by packaging.python.org

Did this fix it?

How do I stop it coming back?

  • Use pip install -r requirements.txt for dependencies and pip install . only for real packages.
  • Print pwd and ls in a failing CI step before you change anything.
  • Run pip through python -m pip so it uses the interpreter you expect.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

pip cannot find setuptools while building a package

setuptools not available in build environment

pip builds source packages in a clean, isolated environment and installs only what the package lists under build-system requires.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.