pip install says the directory is not installable
ERROR: Directory is not installable. Neither 'setup.py' nor 'pyproject.toml' foundShort 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.
Fix it fast
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.py2Match what you see, then jump to its fix
- 1
The 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
ls 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
The folder holds your code but neither pyproject.toml nor setup.pyThe project is a package but has no build metadataFix
- 1
What does the error look like?
ERROR: Directory is not installable. Neither 'setup.py' nor 'pyproject.toml' foundpip 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.txt2Fix
Install from the requirements file.
python -m pip install -r requirements.txt3Verify
pip resolves and installs the listed packages.
python -m pip listConfirmed by pip.pypa.io
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 -la2Fix
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
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.py2Fix
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
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
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 fixServers
You cannot pip install packages inside an Ubuntu Docker container
error: externally-managed-environment
If pip is missing, install the python3-pip package with apt, in the same RUN as apt-get update.
3 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
pip install cryptography tries to compile and fails in a Docker build
fatal error: 'openssl/aes.h' file not found
cryptography ships prebuilt wheels.
3 causes, each with a fixServers
Docker build fails with apk: not found in a Python or Ubuntu image
/bin/sh: 1: apk: not found
apk is the package manager of Alpine Linux only.
2 causes, each with a fixServers
Docker cannot find manage.py or Permission denied on '/manage.py'
PermissionError: [Errno 13] Permission denied: '/manage.py'
The container is looking for manage.py in a directory where the file is not.
3 causes, each with a fix