{"id":"5f48006131f66afd","repo":"pypa/pip","slug":"python-full-version-env-python-full-version-r-in","errorCode":null,"errorMessage":"python_full_version {env_python_full_version!r} in provided environment does not satisfy the Python version requirement {str(self.requires_python)!r}","messagePattern":"python_full_version (.+?) in provided environment does not satisfy the Python version requirement (.+?)","errorType":"exception","errorClass":"PylockSelectError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":801,"sourceCode":"            ),\n        )\n        env_python_full_version = (\n            environment[\"python_full_version\"]\n            if environment\n            else default_environment()[\"python_full_version\"]\n        )\n\n        # #. Check if the metadata version specified by :ref:`pylock-lock-version` is\n        #    supported; an error or warning MUST be raised as appropriate.\n        # Covered by lock.validate() which is a precondition for this method.\n\n        # #. If :ref:`pylock-requires-python` is specified, check that the environment\n        #    being installed for meets the requirement; an error MUST be raised if it is\n        #    not met.\n        if self.requires_python and not self.requires_python.contains(\n            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\"","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/packaging/pylock.py#L783-L819","documentation":"Raised as PylockSelectError (pylock.py:801) by Pylock.select() when the lock-level requires-python specifier set is not satisfied by python_full_version of the selection environment. It is the first guard inside select(): if the whole lock requires Python >=3.10 and you select for 3.9, it fails before any package logic runs.","triggerScenarios":"Calling pylock.select(environment={'python_full_version': '3.9.1', ...}) on a lock whose [root] requires-python = '>=3.10'. Also triggered when environment is omitted and default_environment()['python_full_version'] (the running interpreter) violates requires-python.","commonSituations":"CI runs the lock on a different Python than the author used. A user omits the environment argument and the host Python is older than the lock allows. Cross-platform lock installed under the wrong interpreter.","solutions":["Switch to a Python interpreter whose full version satisfies the lock's requires-python.","Pass an explicit environment dict whose python_full_version satisfies requires-python, if you are selecting for a different target than the host.","Loosen requires-python in the lock (only if you control it and it is actually compatible)."],"exampleFix":"# before: lock says requires-python = \">=3.11\"; host is 3.10\npylock.select()\n\n# after\npylock.select(environment={'python_full_version': '3.11.6',\n                            'python_version': '3.11',\n                            'os_name': 'posix',\n                            'sys_platform': 'linux'})","handlingStrategy":"validation","validationCode":"from pip._vendor.packaging.specifiers import SpecifierSet\ndef env_satisfies_lock_python(requires_python, python_full_version):\n    return (not requires_python) or SpecifierSet(requires_python).contains(python_full_version)","typeGuard":"null","tryCatchPattern":"from pip._vendor.packaging.pylock import PylockSelectError\ntry:\n    list(pylock.select(environment=env))\nexcept PylockSelectError as e:\n    if 'requires-python' in str(e) or 'Python version requirement' in str(e):\n        switch_interpreter_or_env(e)","preventionTips":["Pass an explicit environment dict that matches your target interpreter.","Keep the lock's requires-python aligned with the interpreters you actually run."],"tags":["pylock","select","python-version","environment"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}