{"id":"a3bdb4d9a97d2847","repo":"pypa/pip","slug":"requested-ireq-has-inconsistent-version-between","errorCode":null,"errorMessage":"Requested {ireq} has inconsistent Version 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 Version 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":302,"sourceCode":"    Compare ``Name``, ``Version``, ``Requires-Dist``, ``Requires-Python``\n    and ``Provides-Extra`` between the two and abort the install on any\n    mismatch as PEP 658 requires the metadata files \"MUST be identical\".\n\n    While the PEP doesn't mandate that consumers enforce the identical\n    requirement, it's good nonetheless to check to prevent confusing\n    behaviour when an index misbehaves.\n\n    Also note for name and version, pip usually rejects wheels if they're\n    inconsistent already. Checking them again here is purely defensive.\n    \"\"\"\n\n    sidecar_name = canonicalize_name(sidecar_dist.raw_name)\n    wheel_name = canonicalize_name(wheel_dist.raw_name)\n    if sidecar_name != wheel_name:\n        raise SidecarMetadataInconsistent(req, \"Name\", sidecar_name, wheel_name)\n\n    if sidecar_dist.version != wheel_dist.version:\n        raise SidecarMetadataInconsistent(\n            req,\n            \"Version\",\n            str(sidecar_dist.version),\n            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)),","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/operations/prepare.py#L284-L320","documentation":"Raised as SidecarMetadataInconsistent for the Version field when the PEP 658 .metadata sidecar's version differs from the wheel's METADATA version. Checked at prepare.py:301-307 during _check_sidecar_matches_wheel; both values are stringified for the message.","triggerScenarios":"The index's .metadata sidecar advertises a different version than the wheel it accompanies. This happens when an index mirrors a wheel but keeps a stale .metadata from a prior version, or a CDN serves mismatched cached objects.","commonSituations":"Mirror/CDN cache desync, a private index that doesn't invalidate .metadata on wheel re-upload, or partial replication. Surfaces only for remote wheels using PEP 658 metadata.","solutions":["Purge pip's cache (pip cache purge) and any HTTP cache/proxy, then reinstall.","Pin to the exact version from the official index: pip install --index-url https://pypi.org/simple/ 'pkg==1.2.3'.","Download the wheel directly by a verified URL/hash to skip the sidecar path.","If self-hosting the index, regenerate and re-publish .metadata files whenever wheels change."],"exampleFix":"# before\npip install pkg  # sidecar says 1.2, wheel says 1.3\n\n# after\npip install --index-url https://pypi.org/simple/ 'pkg==1.3.0'","handlingStrategy":"fallback","validationCode":"# compare sidecar version vs wheel METADATA version\nif str(sidecar_version) != str(wheel_version):\n    logger.warning(\"sidecar/wheel version mismatch; using direct wheel URL\")","typeGuard":"def versions_match(a, b) -> bool:\n    return str(a) == str(b)","tryCatchPattern":null,"preventionTips":["Pin to an exact version and verified index to bypass stale sidecars.","Keep CDN/mirror caches consistent with .metadata regeneration.","Purge local pip cache on first occurrence to rule out client-side staleness."],"tags":["metadata","pep658","sidecar","packaging","version"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}