{"id":"218fc8919057b4dd","repo":"pypa/pip","slug":"requested-ireq-has-inconsistent-requires-python","errorCode":null,"errorMessage":"Requested {ireq} has inconsistent Requires-Python between its PEP 658 .metadata file and the wheel's METADATA: sidecar has {f_val!r}, wheel has {m_val!r}","messagePattern":"Requested (.+?) has inconsistent Requires-Python between its PEP 658 \\.metadata file and the wheel's METADATA: sidecar has (.+?), wheel has (.+?)","errorType":"exception","errorClass":"SidecarMetadataInconsistent","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/operations/prepare.py","lineNumber":324,"sourceCode":"            str(wheel_dist.version),\n        )\n\n    # For multi-use fields, only report the symmetric difference to avoid\n    # unnecessarily flagging matching values.\n    sidecar_requires = _canonical_requires(\n        req, sidecar_dist, \"the PEP 658 .metadata file\"\n    )\n    wheel_requires = _canonical_requires(req, wheel_dist, \"the wheel's METADATA\")\n    if sidecar_requires != wheel_requires:\n        raise SidecarMetadataInconsistent(\n            req,\n            \"Requires-Dist\",\n            \", \".join(sorted(sidecar_requires - wheel_requires)),\n            \", \".join(sorted(wheel_requires - sidecar_requires)),\n        )\n\n    if sidecar_dist.requires_python != wheel_dist.requires_python:\n        raise SidecarMetadataInconsistent(\n            req,\n            \"Requires-Python\",\n            str(sidecar_dist.requires_python),\n            str(wheel_dist.requires_python),\n        )\n\n    sidecar_extras = frozenset(sidecar_dist.iter_provided_extras())\n    wheel_extras = frozenset(wheel_dist.iter_provided_extras())\n    if sidecar_extras != wheel_extras:\n        raise SidecarMetadataInconsistent(\n            req,\n            \"Provides-Extra\",\n            \", \".join(sorted(sidecar_extras - wheel_extras)),\n            \", \".join(sorted(wheel_extras - sidecar_extras)),\n        )\n\n\nclass RequirementPreparer:","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/operations/prepare.py#L306-L342","documentation":"Raised as SidecarMetadataInconsistent for Requires-Python when the Python-version constraint in the PEP 658 .metadata sidecar differs from the wheel's METADATA. Checked at prepare.py:323-329; both values stringified. A mismatch could mislead the resolver into accepting or rejecting a wheel for the wrong Python versions.","triggerScenarios":"The sidecar's Requires-Python specifier differs from the wheel's METADATA Requires-Python. E.g. sidecar says '>=3.8', wheel says '>=3.9'. Occurs for remote wheels fetched via PEP 658 metadata.","commonSituations":"Index/mirror serving a stale .metadata from when the package supported a broader Python range. CDN caching issues. Re-uploaded wheel with a tightened Requires-Python but unchanged .metadata.","solutions":["Purge caches: pip cache purge, clear any mirror/CDN cache, then retry.","Reinstall from the official index with the version pinned: pip install --index-url https://pypi.org/simple/ 'pkg==<ver>'.","Verify your interpreter satisfies the wheel's actual Requires-Python by inspecting the wheel METADATA directly.","Notify the index maintainer to regenerate .metadata on every wheel change."],"exampleFix":"# before: sidecar Requires-Python >=3.8, wheel requires >=3.9 (on Python 3.8)\npip install pkg  # -> SidecarMetadataInconsistent Requires-Python\n\n# after: use a compatible Python or correct index\npython3.9 -m pip install --index-url https://pypi.org/simple/ 'pkg==1.0.0'","handlingStrategy":"validation","validationCode":"# compare Requires-Python from sidecar vs wheel\nif str(sidecar_requires_python) != str(wheel_requires_python):\n    logger.warning(\"Requires-Python mismatch; trusting wheel METADATA\")","typeGuard":"def requires_python_match(a, b) -> bool:\n    return str(a) == str(b)","tryCatchPattern":null,"preventionTips":["Confirm your interpreter satisfies the wheel's actual Requires-Python before install.","Pin exact versions from a trusted index to avoid stale sidecars.","Regenerate .metadata on Python-range changes for self-hosted indices."],"tags":["metadata","pep658","sidecar","requires-python","packaging"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}