/errors/poetry/could-not-find-pyproject-toml
Poetry could not find a pyproject.toml file in /path or its parents
- tool
- Poetry
- exit code
- 1
- versions
- Poetry 1.x – 2.x
- os
- any
Poetry could not find a pyproject.toml file in /path or its parents means a Poetry command that works on a project (poetry install, add, lock, run, shell) found no pyproject.toml in the current directory or any directory above it. Change into the project folder, run it with poetry -C path/to/project install, or create the file with poetry init.
Reproduce it
uvx -q poetry@2.5.1 installOutput · exit 1
Poetry could not find a pyproject.toml file in /tmp/work or its parents
Fix
Create a minimal project and run Poetry against it from another directory with -C:
mkdir app
cat > app/pyproject.toml <<'EOF'
[project]
name = "demo"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = []
[tool.poetry]
package-mode = false
EOF
uvx -q poetry@2.5.1 -C app checkOutput
All set!
package-mode = false tells Poetry the project is only used to manage dependencies, not built as a package, so it needs no source folder.
Creating a pyproject.toml
| Situation | Command |
|---|---|
| Existing folder with code | poetry init (interactive; -n accepts defaults) |
| New project from scratch | poetry new NAME (creates the folder, src layout and tests) |
| Project with requirements.txt | poetry init -n, then poetry add each requirement (for example xargs poetry add < requirements.txt) |
Poetry 2 writes standard [project] metadata (PEP 621) into pyproject.toml; Poetry 1.x used [tool.poetry] for name, version and dependencies. Both versions find the file the same way.