{"record":{"id":"922f5c6255a691e9","repo":"pypa/pip","slug":"wheel-name-located-at-location-is-invalid-922f5c","errorCode":null,"errorMessage":"Wheel '{name}' located at {location} is invalid.","messagePattern":"Wheel '(.+?)' located at (.+?) is invalid\\.","errorType":"exception","errorClass":"InvalidWheel","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/metadata/pkg_resources.py","lineNumber":149,"sourceCode":"        dist = pkg_resources.DistInfoDistribution(\n            location=filename,\n            metadata=InMemoryMetadata(metadata_dict, filename),\n            project_name=project_name,\n        )\n        return cls(dist)\n\n    @classmethod\n    def from_wheel(cls, wheel: Wheel, name: str) -> BaseDistribution:\n        try:\n            with wheel.as_zipfile() as zf:\n                info_dir, _ = parse_wheel(zf, name)\n                metadata_dict = {\n                    path.split(\"/\", 1)[-1]: read_wheel_metadata_file(zf, path)\n                    for path in zf.namelist()\n                    if path.startswith(f\"{info_dir}/\")\n                }\n        except zipfile.BadZipFile as e:\n            raise InvalidWheel(wheel.location, name) from e\n        except UnsupportedWheel as e:\n            raise UnsupportedWheel(f\"{name} has an invalid wheel, {e}\")\n        dist = pkg_resources.DistInfoDistribution(\n            location=wheel.location,\n            metadata=InMemoryMetadata(metadata_dict, wheel.location),\n            project_name=name,\n        )\n        return cls(dist)\n\n    @property\n    def location(self) -> str | None:\n        return self._dist.location\n\n    @property\n    def installed_location(self) -> str | None:\n        egg_link = egg_link_path_from_location(self.raw_name)\n        if egg_link:\n            location = egg_link","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/metadata/pkg_resources.py#L131-L167","documentation":"Raised as InvalidWheel from Distribution.from_wheel in pkg_resources.py:139-149 when wheel.as_zipfile() raises zipfile.BadZipFile. The pkg_resources-based metadata backend opens the wheel as a zip to extract the dist-info metadata; a structurally corrupt wheel triggers BadZipFile, wrapped as InvalidWheel(location, name).","triggerScenarios":"Distribution.from_wheel(wheel, name) in the pkg_resources backend; the zip is corrupt/truncated so zipfile.BadZipFile is raised and re-raised as InvalidWheel.","commonSituations":"Corrupted/partial wheel download (network/proxy issue), a file not actually a zip renamed .whl, disk corruption, or a stale partial file in the cache.","solutions":["Purge pip's cache (pip cache purge) and re-download the wheel.","Verify the wheel size/hash against the index; re-download if mismatched.","Rebuild the wheel locally if it is your own package."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before opening the wheel, verify it is a complete, valid zip:\nimport zipfile\nif not zipfile.is_zipfile(wheel.location):\n    raise SystemExit(f'{wheel.location} corrupt; re-download')","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import InvalidWheel\ntry:\n    dist = Distribution.from_wheel(wheel, name)\nexcept InvalidWheel:\n    # purge cache and re-download\n    ...","preventionTips":["Verify wheel hashes after download to detect corruption.","Clear pip cache when BadZipFile/InvalidWheel recurs.","Use checksummed, retried downloads in CI."],"tags":["wheel","corruption","zipfile","pkg-resources"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}