pythonpython-poetry

Why is Poetry complaining that `name` isn't set in pyproject.toml?


I set up a new Python Poetry project with poetry init. I'm not creating a package, so I added this to my pyproject.toml:

[tool.poetry]
package-mode = false

The Operating Modes section of the Poetry documentation says that when operating in non-package mode, the name and version fields in pyproject.toml are optional, so I removed them.

Now when I run a Poetry command, such as poetry env list, I get this error:

The Poetry configuration is invalid:
  - project must contain ['name'] properties

Why is this happening?


Solution

  • This is a known issue: Poetry Issue 10032. More context is available in Issues 10031 and 10033.

    It does not matter if poetry.tools.package-mode = false, the project.name field is still required, because per the official standardized specification of the [project] table:

    A [project] table must include a name key.

    This behavior was initially unclear in Poetry's documentation, but updates clarify it, as discussed in Poetry Issue 10033.

    The solution is to use the [tool.poetry] table instead of the [project] table. Indeed, the [project] table is meant to be used only for projects intended to be packaged, built, and distributed as sdist and/or wheel, for example on a Python package index such as PyPI. So using the [project] table for a "non-package" project is nonsensical. Use the [tool.poetry] table for such projects.