pypa/pip · error · InstallationError
Cannot select requirements from pylock file {pylock_path_or_
Error message
Cannot select requirements from pylock file {pylock_path_or_url!r}: {exc} What it means
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.
Source
Thrown at src/pip/_internal/utils/pylock.py:297
raise
except Exception as exc:
raise InstallationError(
f"Error reading pylock file {pylock_path_or_url!r}: {exc}"
) from exc
try:
lock = Pylock.from_dict(tomllib.loads(pylock_content))
except Exception as exc:
raise InstallationError(
f"Invalid pylock file {pylock_path_or_url!r}: {exc}"
) from exc
try:
# TODO: for completeness, pylock.select should support preferring sdist
# over wheels to support --no-binary
yield from lock.select()
except Exception as exc:
raise InstallationError(
f"Cannot select requirements from pylock file {pylock_path_or_url!r}: {exc}"
) from exc
View on GitHub (pinned to d7d0d0a394)
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.
Example fix
// before # lock built on linux, installing on windows -> no wheel matches pip install pylock.toml // after # regenerate including windows wheels, or install on the target platform: uv lock --python-platform windows pip install pylock.toml
Defensive patterns
Strategy: validation
Validate before calling
import tomllib, platform
major, minor = platform.python_version_tuple()[:2]
data = tomllib.load(open('pylock.toml','rb'))
has_artifact = any(
'wheels' in p or 'sdist' in p or 'vcs' in p or 'directory' in p
for p in data.get('packages', [])
)
if not has_artifact:
raise SystemExit('pylock has no installable artifacts for this environment') Type guard
null
Try / catch
null
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid pylock file {pylock_path_or_url!r}: {exc}
- {link.filename} is not a supported wheel on this platform.
- Path {path!r} in pylock file obtained from a URL resolves ou
- Absolute paths are not supported in pylock files obtained fr
- Package URL {url!r} cannot contain fragments in combination
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/59e57f6c58475bb4.json.
Report an issue: GitHub.