pypa/pip · error · ValueError
Duplicate entry point
Error message
Duplicate entry point
What it means
Raised by EntryPoint.parse_group when two entry points within the same group share the same name (the 'name' left of '='). pkg_resources builds a dict keyed by entry point name per group, so duplicates are ambiguous and rejected with ValueError('Duplicate entry point', group, name).
Source
Thrown at src/pip/_vendor/pkg_resources/__init__.py:2827
if req.specs:
raise ValueError
return req.extras
@classmethod
def parse_group(
cls,
group: str,
lines: _NestedStr,
dist: Distribution | None = None,
):
"""Parse an entry point group"""
if not MODULE(group):
raise ValueError("Invalid group name", group)
this: dict[str, Self] = {}
for line in yield_lines(lines):
ep = cls.parse(line, dist)
if ep.name in this:
raise ValueError("Duplicate entry point", group, ep.name)
this[ep.name] = ep
return this
@classmethod
def parse_map(
cls,
data: str | Iterable[str] | dict[str, str | Iterable[str]],
dist: Distribution | None = None,
):
"""Parse a map of entry point groups"""
_data: Iterable[tuple[str | None, str | Iterable[str]]]
if isinstance(data, dict):
_data = data.items()
else:
_data = split_sections(data)
maps: dict[str, dict[str, Self]] = {}
for group, lines in _data:
if group is None:View on GitHub (pinned to d7d0d0a394)
Solutions
- Inspect entry_points.txt for the reported group and remove/rename the duplicate key so each name appears once.
- If duplicates come from multiple installed distributions, uninstall or upgrade the conflicting package so only one defines that entry point.
- Regenerate metadata from setup.cfg/pyproject.toml after de-duplicating the [project.scripts]/entry_points entries.
Example fix
# before [console_scripts] foo = pkg.a:main foo = pkg.b:run # after [console_scripts] foo = pkg.a:main bar = pkg.b:run
Defensive patterns
Strategy: validation
Validate before calling
names = [ep.split('=', 1)[0].strip() for ep in lines if ep.strip()]
if len(names) != len(set(names)):
dupes = {n for n in names if names.count(n) > 1}
raise ValueError(f'duplicate entry points: {dupes}')
EntryPoint.parse_group(group, lines) Type guard
def has_unique_names(entry_lines):
seen = set()
for ln in entry_lines:
if '=' in ln:
n = ln.split('=', 1)[0].strip()
if n in seen:
return False
seen.add(n)
return True Try / catch
try:
EntryPoint.parse_group(group, lines)
except ValueError as e:
if 'Duplicate entry point' in str(e):
# de-duplicate lines, then retry
...
raise Prevention
- Maintain entry_points in pyproject.toml where the build backend enforces uniqueness.
- Run a pre-publish check that asserts unique names per group.
When it happens
Trigger: An entry_points.txt section lists the same key twice, e.g. '[console_scripts]\nfoo=a:main\nfoo=b:main', and pkg_resources parses that group via parse_group/parse_map.
Common situations: Merging entry_points from multiple packages that both define the same console script, a copy-paste error in metadata, or a packaging plugin that appends rather than replaces.
Related errors
- Duplicate group name
- Invalid group name
- Entry points must be listed in groups
- Missing 'Version:' header and/or {} file at path: {}
- Entry point %r not found
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/f15f5444e18b4985.json.
Report an issue: GitHub.