{"record":{"id":"a14416b8ea57522b","repo":"pypa/pip","slug":"provided-environment-does-not-satisfy-any-of-the-e","errorCode":null,"errorMessage":"Provided environment does not satisfy any of the environments specified in the lock file","messagePattern":"Provided environment does not satisfy any of the environments specified in the lock file","errorType":"exception","errorClass":"PylockSelectError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":846,"sourceCode":"            env_python_full_version,\n        ):\n            raise PylockSelectError(\n                f\"python_full_version {env_python_full_version!r} \"\n                f\"in provided environment does not satisfy the Python version \"\n                f\"requirement {str(self.requires_python)!r}\"\n            )\n\n        # #. If :ref:`pylock-environments` is specified, check that at least one of the\n        #    environment marker expressions is satisfied; an error MUST be raised if no\n        #    expression is satisfied.\n        if self.environments:\n            for env_marker in self.environments:\n                if env_marker.evaluate(\n                    cast(\"dict[str, str]\", environment or {}), context=\"requirement\"\n                ):\n                    break\n            else:\n                raise PylockSelectError(\n                    \"Provided environment does not satisfy any of the \"\n                    \"environments specified in the lock file\"\n                )\n\n        # #. For each package listed in :ref:`pylock-packages`:\n        selected_packages_by_name: dict[str, tuple[int, Package]] = {}\n        for package_index, package in enumerate(self.packages):\n            # #. If :ref:`pylock-packages-marker` is specified, check if it is\n            #    satisfied;if it isn't, skip to the next package.\n            if package.marker and not package.marker.evaluate(env, context=\"lock_file\"):\n                continue\n\n            # #. If :ref:`pylock-packages-requires-python` is specified, check if it is\n            #    satisfied; an error MUST be raised if it isn't.\n            if package.requires_python and not package.requires_python.contains(\n                env_python_full_version,\n            ):\n                raise PylockSelectError(","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/packaging/pylock.py#L828-L864","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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.)."],"exampleFix":"# before: lock environments = [\"platform_system == 'Linux'\"]\npylock.select()  # raised on macOS\n\n# after: select with an environment that satisfies the marker\nimport packaging.markers\npylock.select(environment={**packaging.markers.default_environment(), 'platform_system': 'Linux'})","handlingStrategy":"validation","validationCode":"from packaging.markers import default_environment\n\ndef env_matches_any_lock_environment(lock_environments, environment=None) -> bool:\n    if not lock_environments:\n        return True\n    env = environment or default_environment()\n    return any(m.evaluate(env, context='requirement') for m in lock_environments)\n\nassert env_matches_any_lock_environment(pylock.environments, env), pylock.environments","typeGuard":"null","tryCatchPattern":"from packaging.pylock import PylockSelectError\ntry:\n    list(pylock.select(environment=env))\nexcept PylockSelectError as e:\n    # none of the environments markers matched; broaden markers or change env\n    report(e)","preventionTips":["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."],"tags":["pylock","packaging","select","environment","markers"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}