{"record":{"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/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/operations/prepare.py#L284-L320","documentation":"Raised by _check_sidecar_matches_wheel (prepare.py:301) as SidecarMetadataInconsistent for the Version field. The PEP 658 sidecar's version must equal the wheel's version; a divergence means the resolver planned against one version while a different one would be installed. pip rejects this defensively per the PEP's 'MUST be identical' requirement.","triggerScenarios":"The downloaded PEP 658 .metadata sidecar advertises a different version than the wheel's METADATA Version field. Comparison is done on sidecar_dist.version vs wheel_dist.version.","commonSituations":"A mirror partially updated a package (new wheel, old sidecar) or vice-versa; a re-upload of the same filename with different contents on an index that does not invalidate the sidecar cache; race conditions on a custom artifact server.","solutions":["Use a different/more-up-to-date index or the official PyPI.","Purge the local pip cache and retry.","Contact the index maintainer to regenerate the PEP 658 sidecar metadata.","Pin the exact version explicitly so pip resolves the correct wheel."],"exampleFix":"# before\npip install pkg\n# after\npip install --no-cache-dir 'pkg==2.0.1'\npip cache purge","handlingStrategy":"validation","validationCode":"from email.parser import Parser\nimport zipfile, io, requests\n\ndef sidecar_version_matches(wheel_url: str, sidecar_url: str) -> bool:\n    wb = requests.get(wheel_url).content\n    zf = zipfile.ZipFile(io.BytesIO(wb))\n    meta = zf.read(next(n for n in zf.namelist() if n.endswith('.dist-info/METADATA'))).decode()\n    v_w = Parser().parsestr(meta)['Version']\n    v_s = Parser().parsestr(requests.get(sidecar_url).text)['Version']\n    return v_s == v_w","typeGuard":"def versions_match(sidecar_version: str, wheel_version: str) -> bool:\n    return str(sidecar_version) == str(wheel_version)","tryCatchPattern":"# Pin an exact version and use a trusted index to bypass mirror inconsistency.\nfrom subprocess import run\nrun([\"pip\", \"install\", \"--no-cache-dir\", \"-i\", \"https://pypi.org/simple/\", f\"{pkg}=={ver}\"], check=True)","preventionTips":["Pin exact versions to avoid resolver picking a wheel whose sidecar is stale.","Use trusted indexes for reproducible installs.","Mirror operators: regenerate sidecars atomically with wheel uploads."],"tags":["pep658","metadata","sidecar","version","index","pip"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}