Skip to content

/errors/poetry/could-not-find-pyproject-toml

Poetry could not find a pyproject.toml file in /path or its parents

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
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

bash
uvx -q poetry@2.5.1 install

Output · 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:

bash
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 check

Output

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

SituationCommand
Existing folder with codepoetry init (interactive; -n accepts defaults)
New project from scratchpoetry new NAME (creates the folder, src layout and tests)
Project with requirements.txtpoetry 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.

Sources