{"record":{"id":"a1fefd2fb0d9c22d","repo":"pypa/pip","slug":"could-not-install-locked-package-project-name-r","errorCode":null,"errorMessage":"Could not install locked package {project_name!r} from {locked_link.comes_from!r}: {detail}","messagePattern":"Could not install locked package (.+?) from (.+?): (.+?)","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/index/package_finder.py","lineNumber":902,"sourceCode":"        All versions found are returned as an InstallationCandidate list.\n\n        See LinkEvaluator.evaluate_link() for details on which files\n        are accepted.\n        \"\"\"\n        if project_name in self._all_candidates:\n            return self._all_candidates[project_name]\n\n        link_evaluator = self.make_link_evaluator(project_name)\n\n        if locked_link := self._locked_links.get(canonicalize_name(project_name)):\n            # If a locked link is known for that project, do not check\n            # index_urls nor find_links. We don't use get_install_candidate here,\n            # because if a locked link is unsupported (due to format control,\n            # release control or otherwise), we want to error out immediately\n            # instead of ignoring it.\n            result, detail = link_evaluator.evaluate_link(locked_link)\n            if result != LinkType.candidate:\n                raise InstallationError(\n                    f\"Could not install locked package {project_name!r} \"\n                    f\"from {locked_link.comes_from!r}: {detail}\"\n                )\n            self._all_candidates[project_name] = [\n                InstallationCandidate(project_name, detail, locked_link, locked=True)\n            ]\n            return self._all_candidates[project_name]\n\n        collected_sources = self._link_collector.collect_sources(\n            project_name=project_name,\n            candidates_from_page=functools.partial(\n                self.process_project_url,\n                link_evaluator=link_evaluator,\n            ),\n        )\n\n        page_candidates_it = itertools.chain.from_iterable(\n            source.page_candidates()","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/index/package_finder.py#L884-L920","documentation":"Raised inside the locked-link code path of find_best_candidate (package_finder.py:900-905). When a lock file pins a specific link for a project, pip skips normal index resolution and evaluates only that locked link; if it fails the LinkEvaluator (wrong format, yanked, requires-python mismatch, release/format control rejection) pip raises InstallationError instead of falling back to the index, because a lock is an explicit, non-negotiable constraint.","triggerScenarios":"Installing from a pip lock/resolution set where the pinned link is excluded by --only-binary/--no-binary format control, fails the requires_python check, is yanked, or is otherwise rejected by evaluate_link. Triggered via the locked-link resolution in find_best_candidate.","commonSituations":"A lock file generated on one platform being applied on another (different Python version -> requires_python mismatch); format-control options (--only-binary=:all:) that forbid the source/binary type of the locked artifact; a locked link that was later yanked or removed upstream.","solutions":["Re-generate the lock file on the target platform/Python version so the pinned link passes evaluate_link there.","Relax the conflicting --only-binary/--no-binary or release-control setting so the locked artifact's format is allowed.","Remove or update the offending locked entry so pip re-resolves from the index."],"exampleFix":"// before: lock pins source dist but install runs with --only-binary=:all:\npip install --only-binary=:all: --require-hashes -r locked.txt\n// after: allow the sdist format the lock expects\npip install --require-hashes -r locked.txt","handlingStrategy":"validation","validationCode":"// Before applying a lock, pre-check the locked link against current format/release control:\nfrom pip._internal.index.package_finder import LinkType\nresult, detail = link_evaluator.evaluate_link(locked_link)\nif result != LinkType.candidate:\n    raise SystemExit(f'locked link for {project_name} will fail: {detail}')","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import InstallationError\ntry:\n    best = finder.find_best_candidate(req)\nexcept InstallationError as e:\n    if 'Could not install locked package' in str(e):\n        # fall back to full index resolution instead of the lock\n        ...","preventionTips":["Generate lock files on the same platform/Python version where they will be applied.","Keep --only-binary/--no-binary settings consistent between lock generation and install.","Pre-validate locked links with the same LinkEvaluator before committing the lock."],"tags":["installation","lock-file","format-control","resolution"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}