{"id":"d5903571b7065fb6","repo":"pypa/pip","slug":"version-in-wheel-filename-r-is-not-consistent-wi","errorCode":null,"errorMessage":"Version in {wheel.filename!r} is not consistent with package version {str(package.version)!r}","messagePattern":"Version in (.+?) is not consistent with package version (.+?)","errorType":"validation","errorClass":"PylockValidationError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":612,"sourceCode":"                \"Exactly one of vcs, directory, archive must be set \"\n                \"if sdist and wheels are not set\"\n            )\n        for i, wheel in enumerate(package.wheels or []):\n            try:\n                (name, version, _, _) = parse_wheel_filename(wheel.filename)\n            except Exception as e:\n                raise PylockValidationError(\n                    f\"Invalid wheel filename {wheel.filename!r}\",\n                    context=f\"wheels[{i}]\",\n                ) from e\n            if name != package.name:\n                raise PylockValidationError(\n                    f\"Name in {wheel.filename!r} is not consistent with \"\n                    f\"package name {package.name!r}\",\n                    context=f\"wheels[{i}]\",\n                )\n            if package.version and version != package.version:\n                raise PylockValidationError(\n                    f\"Version in {wheel.filename!r} is not consistent with \"\n                    f\"package version {str(package.version)!r}\",\n                    context=f\"wheels[{i}]\",\n                )\n        if package.sdist:\n            try:\n                name, version = parse_sdist_filename(package.sdist.filename)\n            except Exception as e:\n                raise PylockValidationError(\n                    f\"Invalid sdist filename {package.sdist.filename!r}\",\n                    context=\"sdist\",\n                ) from e\n            if name != package.name:\n                raise PylockValidationError(\n                    f\"Name in {package.sdist.filename!r} is not consistent with \"\n                    f\"package name {package.name!r}\",\n                    context=\"sdist\",\n                )","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/packaging/pylock.py#L594-L630","documentation":"Raised by Pylock.Package._from_dict (pylock.py:611-616) as a PylockValidationError when a wheel entry's filename encodes a version that differs from the package's declared 'version' field. packaging parses the wheel filename with parse_wheel_filename and compares the resulting version against package.version only when package.version is set. It enforces PEP 753's rule that wheel filenames and the package version metadata must agree.","triggerScenarios":"Loading a pylock TOML via Pylock.from_dict() where a [[packages.wheels]] entry has filename='foo-1.2.3-py3-none-any.whl' but the parent [packages] table sets version='1.2.4'. Also reached indirectly through Pylock.validate(), which round-trips to_dict() back through _from_dict.","commonSituations":"A lock file was hand-edited or generated by a buggy resolver that wrote a wheel filename from one source and the version from another. Re-publishing a project at a new version while leaving stale wheel filenames in the lock also triggers it.","solutions":["Open the pylock TOML and find packages[<index>] reported in the error context (e.g. 'wheels[2]'); align the wheel filename's version segment with the package.version field.","Regenerate the lock file with the tool that produced it (uv/pip) so filenames and versions stay consistent.","If the wheel filename is correct, update package.version to match it; if the version field is correct, replace the wheel filename."],"exampleFix":"# before\n[[packages]]\nname = \"foo\"\nversion = \"1.2.4\"\nwheels = [{ filename = \"foo-1.2.3-py3-none-any.whl\", url = \"...\" }]\n\n# after\n[[packages]]\nname = \"foo\"\nversion = \"1.2.4\"\nwheels = [{ filename = \"foo-1.2.4-py3-none-any.whl\", url = \"...\" }]","handlingStrategy":"validation","validationCode":"from pip._vendor.packaging.utils import parse_wheel_filename\nfrom pip._vendor.packaging.version import Version\n\ndef wheel_version_matches(package_name, package_version, wheel_filename):\n    name, ver, _, _ = parse_wheel_filename(wheel_filename)\n    return name == package_name and (not package_version or ver == Version(package_version))","typeGuard":"null","tryCatchPattern":"from pip._vendor.packaging.pylock import PylockValidationError\ntry:\n    Pylock.from_dict(toml_dict)\nexcept PylockValidationError as e:\n    # e.context points at 'packages[N].wheels[M]'\n    log.error('lock wheel/version mismatch at %s: %s', e.context, e.message)","preventionTips":["Always generate pylock files with a spec-compliant resolver rather than editing by hand.","Treat package.version and wheel filenames as a single atomic unit when editing locks."],"tags":["pylock","validation","packaging","version-mismatch"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}