pypa/pip · error · InstallationError
Error parsing {path}: {e}
Error message
Error parsing {path}: {e} What it means
Raised when the pyproject.toml referenced by '--group' exists but fails to parse as TOML (tomllib.TOMLDecodeError). pip wraps the underlying decoder error so the user sees the offending file and the parser's detail. Dependency-group resolution cannot proceed without valid TOML.
Source
Thrown at src/pip/_internal/req/req_dependency_group.py:84
f"[dependency-groups] data was invalid in {path}: {'; '.join(messages)}"
) from eg
return resolvers
def _load_pyproject(path: str) -> dict[str, Any]:
"""
This helper loads a pyproject.toml as TOML.
It raises an InstallationError if the operation fails.
"""
try:
with open(path, "rb") as fp:
return tomllib.load(fp)
except FileNotFoundError:
raise InstallationError(f"{path} not found. Cannot resolve '--group' option.")
except tomllib.TOMLDecodeError as e:
raise InstallationError(f"Error parsing {path}: {e}") from e
except OSError as e:
raise InstallationError(f"Error reading {path}: {e}") from e
View on GitHub (pinned to d7d0d0a394)
Solutions
- Run a TOML linter/validator on the file (e.g. 'python -c "import tomllib,sys; tomllib.load(open(sys.argv[1],\"rb\"))" ./pyproject.toml') to surface the exact location.
- Open pyproject.toml at the line/column reported in {e} and fix the syntax.
- Remove any git conflict markers ('<<<<<<<', '=======', '>>>>>>>') left from an unresolved merge.
- Re-validate after editing by re-running the tomllib load before retrying pip.
Example fix
# before — pyproject.toml [dependency-groups] dev = ["pytest "ruff"] # missing comma # after [dependency-groups] dev = ["pytest", "ruff"]
Defensive patterns
Strategy: validation
Validate before calling
import tomllib, sys
path = sys.argv[1]
try:
with open(path, 'rb') as f:
tomllib.load(f)
except tomllib.TOMLDecodeError as e:
raise SystemExit(f'fix TOML first: {e}') Type guard
def is_valid_toml(path: str) -> bool:
import tomllib
try:
with open(path, 'rb') as f:
tomllib.load(f)
return True
except (tomllib.TOMLDecodeError, OSError):
return False Try / catch
import tomllib
try:
with open(path, 'rb') as f:
tomllib.load(f)
run_pip(['install', '--group', f'{path}:dev'])
except tomllib.TOMLDecodeError as e:
print(f'TOML invalid: {e}; edit then retry') Prevention
- Validate pyproject.toml in a pre-commit hook with a TOML linter.
- Never commit a file with git conflict markers.
- Run 'python -m tomllib' load in CI before pip.
When it happens
Trigger: Calling 'pip install --group ./pyproject.toml:dev' where pyproject.toml has a syntax error: unterminated string, duplicate keys, a bare value where a table is expected, mixed tabs/spaces in a multiline array, or trailing characters after a value.
Common situations: Hand-editing pyproject.toml and forgetting a quote or comma; merging a branch that left a conflict marker ('<<<<<<<') in the file; tooling that writes partial TOML; copy-pasting a snippet that uses '=' inside an inline table incorrectly.
Related errors
- [dependency-groups] resolution failed for '{groupname}' from
- [dependency-groups] table was missing from '{path}'. Cannot
- [dependency-groups] table was malformed in {path}. Cannot re
- [dependency-groups] data was invalid in {path}: {'; '.join(m
- {path} not found. Cannot resolve '--group' option.
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/54109bd34aeab893.json.
Report an issue: GitHub.