{"id":"05855e3a8dc42b61","repo":"pypa/pip","slug":"package-dist-raw-name-r-requires-a-different-pyt","errorCode":null,"errorMessage":"Package {dist.raw_name!r} requires a different Python: {version} not in {requires_python!r}","messagePattern":"Package (.+?) requires a different Python: (.+?) not in (.+?)","errorType":"exception","errorClass":"UnsupportedPythonVersion","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/resolution/legacy/resolver.py","lineNumber":105,"sourceCode":"        logger.warning(\n            \"Package %r has an invalid Requires-Python: %s\", dist.raw_name, exc\n        )\n        return\n\n    if is_compatible:\n        return\n\n    version = \".\".join(map(str, version_info))\n    if ignore_requires_python:\n        logger.debug(\n            \"Ignoring failed Requires-Python check for package %r: %s not in %r\",\n            dist.raw_name,\n            version,\n            requires_python,\n        )\n        return\n\n    raise UnsupportedPythonVersion(\n        f\"Package {dist.raw_name!r} requires a different Python: \"\n        f\"{version} not in {requires_python!r}\"\n    )\n\n\nclass Resolver(BaseResolver):\n    \"\"\"Resolves which packages need to be installed/uninstalled to perform \\\n    the requested operation without breaking the requirements of any package.\n    \"\"\"\n\n    _allowed_strategies = {\"eager\", \"only-if-needed\", \"to-satisfy-only\"}\n\n    def __init__(\n        self,\n        preparer: RequirementPreparer,\n        finder: PackageFinder,\n        wheel_cache: WheelCache | None,\n        make_install_req: InstallRequirementProvider,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/resolution/legacy/resolver.py#L87-L123","documentation":"UnsupportedPythonVersion raised by the legacy resolver's _check_requires_python when the distribution's Requires-Python specifier excludes the currently running Python version and --ignore-requires-python is not set. pip reads Requires-Python from metadata, compares it to sys.version_info via check_requires_python, and aborts with both the current version and the offending specifier so the user can see the mismatch.","triggerScenarios":"Installing a package whose metadata declares e.g. 'Requires-Python: >=3.9' while running Python 3.8 (or '<4' while on a 4.x). Triggered during dependency resolution when the legacy resolver evaluates a candidate distribution.","commonSituations":"Running an older Python than a package supports; new release that bumped its minimum Python; CI matrix using Python 3.8 for a dependency that now requires 3.9+; pyenv/conda env pointing at the wrong interpreter.","solutions":["Upgrade your interpreter to one satisfying the Requires-Python specifier shown in the error.","Pin an older version of the package that still supports your Python: 'pkg==<older>'.","If you accept the risk, bypass the check with '--ignore-requires-python' (not recommended for production).","Verify which Python pip is using: 'pip -V' and 'python --version'."],"exampleFix":"# before — Python 3.8\npip install 'newpkg>=2.0'   # newpkg>=2.0 requires Python >=3.9\n\n# after (option A: upgrade interpreter; option B: pin older)\npip install 'newpkg<2.0'","handlingStrategy":"validation","validationCode":"import sys\nfrom pip._vendor.packaging.specifiers import SpecifierSet\ndef python_satisfies(requires_python: str) -> bool:\n    return SpecifierSet(requires_python).contains('.'.join(map(str, sys.version_info[:3])))","typeGuard":"def is_python_compatible(requires_python: str) -> bool:\n    return python_satisfies(requires_python)","tryCatchPattern":"from pip._internal.exceptions import UnsupportedPythonVersion\ntry:\n    run_pip(['install', 'pkg'])\nexcept UnsupportedPythonVersion:\n    run_pip(['install', '--ignore-requires-python', 'pkg'])  # or upgrade Python / pin older pkg","preventionTips":["Keep your interpreter within the supported range of your dependencies.","Check Requires-Python before adding a dependency: 'pip index versions pkg'.","Use '--ignore-requires-python' only as a last resort."],"tags":["requires-python","python-version","resolver","compatibility"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}