{"record":{"id":"f5ae6b3df6222588","repo":"pypa/pip","slug":"none-metadata-name-metadata-found-for-distributi","errorCode":null,"errorMessage":"None {metadata_name} metadata found for distribution: {dist}","messagePattern":"None (.+?) metadata found for distribution: (.+?)","errorType":"exception","errorClass":"NoneMetadataError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/metadata/pkg_resources.py","lineNumber":212,"sourceCode":"        return parse_version(self._dist.version)\n\n    @property\n    def raw_version(self) -> str:\n        return self._dist.version\n\n    def is_file(self, path: InfoPath) -> bool:\n        return self._dist.has_metadata(str(path))\n\n    def iter_distutils_script_names(self) -> Iterator[str]:\n        yield from self._dist.metadata_listdir(\"scripts\")\n\n    def read_text(self, path: InfoPath) -> str:\n        name = str(path)\n        if not self._dist.has_metadata(name):\n            raise FileNotFoundError(name)\n        content = self._dist.get_metadata(name)\n        if content is None:\n            raise NoneMetadataError(self, name)\n        return content\n\n    def iter_entry_points(self) -> Iterable[BaseEntryPoint]:\n        try:\n            entry_map = self._dist.get_entry_map()\n        except ValueError as e:\n            raise InstallationError(\n                f\"Error parsing entry points for {self.raw_name}: {e}\"\n            ) from e\n        for group, entries in entry_map.items():\n            for name, entry_point in entries.items():\n                name, _, value = str(entry_point).partition(\"=\")\n                yield EntryPoint(name=name.strip(), value=value.strip(), group=group)\n\n    def _metadata_impl(self) -> email.message.Message:\n        \"\"\"\n        :raises NoneMetadataError: if the distribution reports `has_metadata()`\n            True but `get_metadata()` returns None.","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/metadata/pkg_resources.py#L194-L230","documentation":"Raised as NoneMetadataError(self, name) from Distribution.read_text in pkg_resources.py:206-213. It indicates an inconsistent state: has_metadata(name) returned True (the metadata file is listed) but get_metadata(name) returned None (no content retrievable) — pip cannot proceed reading a metadata file that claims to exist yet yields nothing.","triggerScenarios":"Calling Distribution.read_text on a pkg_resources Distribution where has_metadata reports the file present but get_metadata yields None — e.g. a pathological metadata provider or a half-written egg-info/dist-info.","commonSituations":"A distribution whose egg-info/dist-info directory lists METADATA/PKG-INFO in its index but the actual file is empty/missing due to a crashed or interrupted install; a buggy custom metadata provider.","solutions":["Reinstall the affected package to regenerate a consistent metadata directory.","Delete the broken .egg-info/.dist-info directory so it is not discovered, then reinstall.","If building, ensure the backend always writes complete metadata files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before read_text, confirm metadata is consistently present and non-empty:\nif dist.has_metadata(name):\n    assert dist.get_metadata(name) is not None, f'{name} listed but empty'\ncontent = dist.read_text(name)","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import NoneMetadataError\ntry:\n    content = dist.read_text('METADATA')\nexcept NoneMetadataError:\n    # reinstall the package to repair metadata\n    ...","preventionTips":["Ensure installers write complete metadata atomically.","Reinstall packages whose metadata directories are half-written.","Audit for empty METADATA/PKG-INFO files in site-packages."],"tags":["metadata","pkg-resources","inconsistent","metadata-missing"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}