{"id":"59e57f6c58475bb4","repo":"pypa/pip","slug":"cannot-select-requirements-from-pylock-file-pyloc","errorCode":null,"errorMessage":"Cannot select requirements from pylock file {pylock_path_or_url!r}: {exc}","messagePattern":"Cannot select requirements from pylock file (.+?): (.+?)","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/utils/pylock.py","lineNumber":297,"sourceCode":"        raise\n    except Exception as exc:\n        raise InstallationError(\n            f\"Error reading pylock file {pylock_path_or_url!r}: {exc}\"\n        ) from exc\n\n    try:\n        lock = Pylock.from_dict(tomllib.loads(pylock_content))\n    except Exception as exc:\n        raise InstallationError(\n            f\"Invalid pylock file {pylock_path_or_url!r}: {exc}\"\n        ) from exc\n\n    try:\n        # TODO: for completeness, pylock.select should support preferring sdist\n        # over wheels to support --no-binary\n        yield from lock.select()\n    except Exception as exc:\n        raise InstallationError(\n            f\"Cannot select requirements from pylock file {pylock_path_or_url!r}: {exc}\"\n        ) from exc\n","sourceCodeStart":279,"sourceCodeEnd":300,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/utils/pylock.py#L279-L300","documentation":"Raised after a pylock file parses successfully but pip cannot run its internal `select()` step, which picks one concrete artifact (wheel/sdist/vcs/directory) per package from the lock. Any exception from that selection logic is wrapped as InstallationError with the lock file path and the underlying cause. It indicates a structurally-valid lock whose contents still cannot be resolved to installable requirements.","triggerScenarios":"Invoking select_from_pylock_path_or_url where lock.select() raises — e.g. a package entry has no wheel/sdist/vcs/dir block, has markers that exclude every artifact, references an unsupported package type, or has an inconsistent environment hash. Anything thrown inside Pylock.select bubbles here.","commonSituations":"Lock file was generated for a different platform/interpreter and select() finds no matching artifact for the current environment; a package entry was edited and is missing its `wheels`/`sdist` subsection; lock-version is supported but uses a newer optional field this pip doesn't know how to select from.","solutions":["Run pip with `-v` to expose the underlying exception chained under this message.","Regenerate the lock on the same platform/interpreter where you install so select() can match an artifact.","Check each package entry has at least one selectable artifact (wheel/sdist/vcs/directory) for your environment.","Upgrade pip to a version whose PEP 751 support matches the lock-version in the file."],"exampleFix":"// before\n# lock built on linux, installing on windows -> no wheel matches\npip install pylock.toml\n\n// after\n# regenerate including windows wheels, or install on the target platform:\nuv lock --python-platform windows\npip install pylock.toml","handlingStrategy":"validation","validationCode":"import tomllib, platform\nmajor, minor = platform.python_version_tuple()[:2]\ndata = tomllib.load(open('pylock.toml','rb'))\nhas_artifact = any(\n    'wheels' in p or 'sdist' in p or 'vcs' in p or 'directory' in p\n    for p in data.get('packages', [])\n)\nif not has_artifact:\n    raise SystemExit('pylock has no installable artifacts for this environment')","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Regenerate the lock on each target platform/interpreter.","Run `pip install -v pylock.toml` to surface the underlying select() error.","Match pip version to the tool that produced the lock.","Include wheel artifacts for every supported platform in the lock."],"tags":["pip","pylock","pep751","resolution","platform"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}