pypa/pip · error · PylockSelectError
Provided environment does not satisfy any of the…
Error message
Provided environment does not satisfy any of the environments specified in the lock file
What it means
PylockSelectError raised by Pylock.select when the lock declares an 'environments' list of marker expressions and none of them evaluates true against the provided environment. PEP 751 lets a lock restrict which environments it applies to; if your interpreter matches none of them, selection aborts.
Solutions
- List the lock's environments entries and identify which platform/python markers gate it.
- Run the selection on a machine/interpreter that matches at least one environment marker, or pass an environment= dict whose values satisfy one (e.g. platform_system, python_version).
- If the lock is meant to be universal, regenerate it with broader or no environments.
- Ensure the environment dict includes every key referenced by the markers (platform_system, platform_machine, python_version, etc.).
Example fix
# before: lock environments = ["platform_system == 'Linux'"]
pylock.select() # raised on macOS
# after: select with an environment that satisfies the marker
import packaging.markers
pylock.select(environment={**packaging.markers.default_environment(), 'platform_system': 'Linux'}) Defensive patterns
Strategy: validation
Validate before calling
from packaging.markers import default_environment
def env_matches_any_lock_environment(lock_environments, environment=None) -> bool:
if not lock_environments:
return True
env = environment or default_environment()
return any(m.evaluate(env, context='requirement') for m in lock_environments)
assert env_matches_any_lock_environment(pylock.environments, env), pylock.environments Type guard
null
Try / catch
from packaging.pylock import PylockSelectError
try:
list(pylock.select(environment=env))
except PylockSelectError as e:
# none of the environments markers matched; broaden markers or change env
report(e) Prevention
- Make sure your environment dict includes every key the markers reference.
- Scope lock environments to your real platform matrix, not narrower.
- For universal locks, omit or broaden the environments list.
When it happens
Trigger: Calling pylock.select(environment=...) when the lock has [[environments]] entries like 'platform_system == "Linux"' and 'python_version >= "3.11"' but you run on macOS 3.10. The loop evaluates each env_marker; if none returns True the else branch raises.
Common situations: Platform-specific lock used on the wrong OS/arch; a lock scoped to a Python version band and run outside it; an environment dict missing keys the markers reference (so evaluation falls through).
Related errors
- python_full_version in provided environment does not…
- Multiple packages with the name
- No wheel found matching the provided tags for package
- python_full_version in provided environment does not…
- Cannot serialize marker value containing both quote…
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/a14416b8ea57522b.
Report an issue: GitHub.
Appendix: source
Thrown at src/pip/_vendor/packaging/pylock.py:846
env_python_full_version,
):
raise PylockSelectError(
f"python_full_version {env_python_full_version!r} "
f"in provided environment does not satisfy the Python version "
f"requirement {str(self.requires_python)!r}"
)
# #. If :ref:`pylock-environments` is specified, check that at least one of the
# environment marker expressions is satisfied; an error MUST be raised if no
# expression is satisfied.
if self.environments:
for env_marker in self.environments:
if env_marker.evaluate(
cast("dict[str, str]", environment or {}), context="requirement"
):
break
else:
raise PylockSelectError(
"Provided environment does not satisfy any of the "
"environments specified in the lock file"
)
# #. For each package listed in :ref:`pylock-packages`:
selected_packages_by_name: dict[str, tuple[int, Package]] = {}
for package_index, package in enumerate(self.packages):
# #. If :ref:`pylock-packages-marker` is specified, check if it is
# satisfied;if it isn't, skip to the next package.
if package.marker and not package.marker.evaluate(env, context="lock_file"):
continue
# #. If :ref:`pylock-packages-requires-python` is specified, check if it is
# satisfied; an error MUST be raised if it isn't.
if package.requires_python and not package.requires_python.contains(
env_python_full_version,
):
raise PylockSelectError(View on GitHub (pinned to f399c37189)