python-poetry/poetry · error · GroupNotFoundError
Group(s) not found: {', '.join(message_parts)}
Error message
Group(s) not found: {', '.join(message_parts)} What it means
`GroupNotFoundError` from `_validate_group_options` (group_command.py:117-134) when a dependency group passed to `--with`, `--without`, or `--only` is not declared in `pyproject.toml` (neither `[tool.poetry.group.<g>]` nor `[dependency-groups]`). Poetry validates group names against `package.has_dependency_group` before operating.
Source
Thrown at src/poetry/console/commands/group_command.py:134
def _validate_group_options(self, group_options: dict[str, set[str]]) -> None:
"""
Raises an error if it detects that a group is not part of pyproject.toml
"""
invalid_options = defaultdict(set)
for opt, groups in group_options.items():
for group in groups:
if not self.poetry.package.has_dependency_group(group):
invalid_options[group].add(opt)
if invalid_options:
message_parts = []
for group in sorted(invalid_options):
opts = ", ".join(
f"<fg=yellow;options=bold>--{opt}</>"
for opt in sorted(invalid_options[group])
)
message_parts.append(f"{group} (via {opts})")
raise GroupNotFoundError(f"Group(s) not found: {', '.join(message_parts)}")
View on GitHub (pinned to 92b74dcfe3)
Solutions
- List declared groups with `poetry show --tree` or inspect `[tool.poetry.group]` / `[dependency-groups]` in pyproject.toml.
- Correct the flag to an existing group name.
- If the group should exist, declare it in pyproject.toml first.
Example fix
# before poetry install --with doc # after poetry install --with docs
Defensive patterns
Strategy: validation
Validate before calling
from poetry.factory import Factory
poetry = Factory().create_poetry()
groups = set(poetry.package.dependency_group_names())
requested = {"docs", "test"}
missing = requested - groups
if missing:
raise SystemExit(f"unknown groups: {sorted(missing)}") Type guard
def group_exists(poetry, name: str) -> bool:
return poetry.package.has_dependency_group(name) Prevention
- Derive `--with`/`--without`/`--only` from pyproject.toml at script time.
- Keep group names in a single source of truth.
- Run `poetry show --groups` (or inspect pyproject) before scripting.
When it happens
Trigger: Running `poetry install --with docs` when no `docs` group exists; `--without ci` when there is no `ci` group; typos in group names.
Common situations: Renaming a group in pyproject but forgetting CI flags; assuming a group exists because the directory does; mixing PEP 735 `[dependency-groups]` and legacy `[tool.poetry.group]` names.
Related errors
- Setting {self.argument('key')} does not exist
- You can only pass one value.
- You can only add optional dependencies to the main group
- You must pass exactly 1 value
- "{value}" is an invalid value for {key}
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/105c7b37dad7560c.json.
Report an issue: GitHub.