{"record":{"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/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/resolution/legacy/resolver.py#L87-L123","documentation":"_check_metadata_requires_python (resolver.py:105) raises UnsupportedPythonVersion when the running interpreter's version falls outside the package's Requires-Python specifier and --ignore-requires-python is not set. pip checks this to prevent installing a package that declares it cannot run on the current Python.","triggerScenarios":"Installing a package whose Requires-Python (e.g. >=3.10) excludes the active interpreter (e.g. 3.8) via the legacy resolver path.","commonSituations":"Wrong interpreter or venv active; CI pinned to an old Python; a dependency dropped support for your Python version in a new release.","solutions":["Switch to a compatible Python version (pyenv use 3.x / create a matching venv).","Pin the package to an older release that supports your Python version.","Pass --ignore-requires-python (risky: may install an unusable package)."],"exampleFix":"# before\npip install newpkg   # requires Python >=3.10, you run 3.8\n# after\npyenv install 3.11 && pyenv shell 3.11 && pip install newpkg","handlingStrategy":"validation","validationCode":"# Before installing, check the package's Requires-Python against your interpreter.\nimport sys, subprocess, json\nver = f\"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}\"\n# e.g. using the JSON API\nimport urllib.request\nfor pkg in [\"numpy\"]:\n    data = json.load(urllib.request.urlopen(f\"https://pypi.org/pypi/{pkg}/json\"))\n    rp = data[\"info\"].get(\"requires_python\", \"\")\n    print(f\"{pkg} requires_python={rp}; you run {ver}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep your interpreter on a supported Python version per the project's constraints.","Pin dependency versions known to support your Python.","Use pyenv or pyenv-win to switch Python versions per project."],"tags":["python-version","requires-python","resolver"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}