pypa/pip · error · PylockSelectError

Provided environment does not satisfy any of the environment

Error message

Provided environment does not satisfy any of the environments specified in the lock file

What it means

Raised as PylockSelectError (pylock.py:817) by Pylock.select() when the lock declares an 'environments' list (a list of PEP 508 marker expressions) and none of them evaluate True against the provided environment. It enforces the spec requirement that at least one environment marker must match before selection proceeds.

Source

Thrown at src/pip/_vendor/packaging/pylock.py:817

            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 d7d0d0a394)

Solutions

  1. Pass an environment dict that satisfies at least one entry in the lock's environments list.
  2. Run on a platform/interpreter the lock explicitly targets.
  3. Fix or extend the environments list in the lock to include the target platform's marker.

Example fix

# before: lock has environments = ['platform_system == "Windows"']; running on Linux
pylock.select()

# after: pass a matching environment, or fix the lock
pylock.select(environment={'platform_system': 'Windows',
                            'python_full_version': '3.11.6',
                            'python_version': '3.11'})
Defensive patterns

Strategy: validation

Validate before calling

from pip._vendor.packaging.markers import Marker
def env_matches_any_lock_environment(environments, env_dict):
    return any(Marker(m).evaluate(env_dict) for m in (environments or []))

Type guard

null

Try / catch

from pip._vendor.packaging.pylock import PylockSelectError
try:
    list(pylock.select(environment=env))
except PylockSelectError as e:
    if 'does not satisfy any of the environments' in str(e):
        provide_compatible_environment(e)

Prevention

When it happens

Trigger: Calling pylock.select(environment=env) where env is, say, linux-only but every entry in environments[] is a marker like 'platform_system == "Windows"'. Also fires when environment is omitted and the running interpreter matches none of the listed markers.

Common situations: Cross-platform lock consumed on an unsupported platform/implementation. A marker typo (e.g. 'platform_system == "Linuz"') that never matches anything. Omitting the environment argument on a host that the lock was not authored for.

Related errors


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/a14416b8ea57522b.json. Report an issue: GitHub.