{"record":{"id":"f15f5444e18b4985","repo":"pypa/pip","slug":"duplicate-entry-point","errorCode":null,"errorMessage":"Duplicate entry point","messagePattern":"Duplicate entry point","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/pkg_resources/__init__.py","lineNumber":2827,"sourceCode":"        if req.specs:\n            raise ValueError\n        return req.extras\n\n    @classmethod\n    def parse_group(\n        cls,\n        group: str,\n        lines: _NestedStr,\n        dist: Distribution | None = None,\n    ):\n        \"\"\"Parse an entry point group\"\"\"\n        if not MODULE(group):\n            raise ValueError(\"Invalid group name\", group)\n        this: dict[str, Self] = {}\n        for line in yield_lines(lines):\n            ep = cls.parse(line, dist)\n            if ep.name in this:\n                raise ValueError(\"Duplicate entry point\", group, ep.name)\n            this[ep.name] = ep\n        return this\n\n    @classmethod\n    def parse_map(\n        cls,\n        data: str | Iterable[str] | dict[str, str | Iterable[str]],\n        dist: Distribution | None = None,\n    ):\n        \"\"\"Parse a map of entry point groups\"\"\"\n        _data: Iterable[tuple[str | None, str | Iterable[str]]]\n        if isinstance(data, dict):\n            _data = data.items()\n        else:\n            _data = split_sections(data)\n        maps: dict[str, dict[str, Self]] = {}\n        for group, lines in _data:\n            if group is None:","sourceCodeStart":2809,"sourceCodeEnd":2845,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/pkg_resources/__init__.py#L2809-L2845","documentation":"Raised as ValueError in EntryPoint.parse_group at line 2826-2827 when the same entry point name appears more than once within a single group. The dict `this` tracks seen names; a collision means metadata is ambiguous and cannot be resolved deterministically.","triggerScenarios":"An entry_points.txt or setup.cfg [entry_points] section lists two lines with the same left-hand name under the same group. For example, two 'cli = ...' lines under [console_scripts].","commonSituations":"Merging entry point lists from multiple sources that both define the same name; copy-paste duplication; refactoring that leaves stale entries alongside new ones; automated generation tools that don't deduplicate.","solutions":["Search the entry_points.txt / setup.cfg / pyproject.toml for duplicate names within the same group and remove the stale entry.","If you need multiple targets, use different entry point names for each.","Reinstall the package after fixing the metadata so entry_points.txt is regenerated.","Audit generated entry_points.txt in the .egg-info directory for duplicates."],"exampleFix":"// before: setup.cfg\n// [options.entry_points]\n// console_scripts =\n//     mycli = mypkg:main\n//     mycli = otherpkg:run\n\n// after\n// [options.entry_points]\n// console_scripts =\n//     mycli = mypkg:main","handlingStrategy":"validation","validationCode":"def deduplicate_entry_points(lines):\n    seen = set()\n    result = []\n    for line in lines:\n        name = line.split('=')[0].strip()\n        if name not in seen:\n            seen.add(name)\n            result.append(line)\n    return result","typeGuard":"def has_no_duplicate_names(lines: list[str]) -> bool:\n    names = [l.split('=')[0].strip() for l in lines if '=' in l]\n    return len(names) == len(set(names))\n","tryCatchPattern":"from pkg_resources import EntryPoint\ntry:\n    group_map = EntryPoint.parse_group('console_scripts', lines)\nexcept ValueError as e:\n    if 'Duplicate' in str(e):\n        # deduplicate and retry\n        group_map = EntryPoint.parse_group('console_scripts', deduplicate_entry_points(lines))\n    else:\n        raise\n","preventionTips":["Deduplicate entry point names within each group before packaging.","Audit setup.cfg/pyproject.toml entry_points sections for duplicates.","Regenerate .egg-info after fixing to clear stale metadata."],"tags":["entry-points","pkg-resources","duplicate","metadata"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}