pypa/pip · error · NoneMetadataError
None {metadata_name} metadata found for distribution: {dist}
Error message
None {metadata_name} metadata found for distribution: {dist} What it means
NoneMetadataError raised by _check_requires_python in the legacy resolver when reading the distribution's metadata raises FileNotFoundError — i.e. there is no METADATA/PKG-INFO file at all for the distribution. Without metadata pip cannot read Requires-Python (or anything else), so it cannot decide compatibility and surfaces the underlying file error.
Source
Thrown at src/pip/_internal/resolution/legacy/resolver.py:80
"""
Check whether the given Python version is compatible with a distribution's
"Requires-Python" value.
:param version_info: A 3-tuple of ints representing the Python
major-minor-micro version to check.
:param ignore_requires_python: Whether to ignore the "Requires-Python"
value if the given Python version isn't compatible.
:raises UnsupportedPythonVersion: When the given Python version isn't
compatible.
"""
# This idiosyncratically converts the SpecifierSet to str and let
# check_requires_python then parse it again into SpecifierSet. But this
# is the legacy resolver so I'm just not going to bother refactoring.
try:
requires_python = str(dist.requires_python)
except FileNotFoundError as e:
raise NoneMetadataError(dist, str(e))
try:
is_compatible = check_requires_python(
requires_python,
version_info=version_info,
)
except specifiers.InvalidSpecifier as exc:
logger.warning(
"Package %r has an invalid Requires-Python: %s", dist.raw_name, exc
)
return
if is_compatible:
return
version = ".".join(map(str, version_info))
if ignore_requires_python:
logger.debug(
"Ignoring failed Requires-Python check for package %r: %s not in %r",View on GitHub (pinned to d7d0d0a394)
Solutions
- Clear the pip cache: 'pip cache purge' (and remove ~/.cache/pip or the build dir).
- Upgrade to the new resolver if possible (drop '--use-legacy-resolver') so the failure surfaces more cleanly.
- Re-download or rebuild the offending distribution; verify its .dist-info contains METADATA.
- If the package on the index is broken, pin a known-good version with 'pkg==X.Y.Z'.
Example fix
# before pip install --use-legacy-resolver broken-pkg # NoneMetadataError # after pip cache purge pip install broken-pkg # new resolver; or pin a known-good version
Defensive patterns
Strategy: validation
Validate before calling
def distribution_has_metadata(dist) -> bool:
try:
_ = dist.requires_python
return True
except FileNotFoundError:
return False Type guard
def has_metadata_file(dist_info_dir: str) -> bool:
import os
return os.path.isfile(os.path.join(dist_info_dir, 'METADATA')) Try / catch
from pip._internal.exceptions import NoneMetadataError
try:
run_pip(['install', '--use-legacy-resolver', 'pkg'])
except NoneMetadataError:
run_pip(['cache', 'purge'])
run_pip(['install', 'pkg']) # or pin a known-good version Prevention
- Migrate off the legacy resolver when possible.
- Clear the pip cache on intermittent metadata errors.
- Pin packages to versions known to ship valid metadata.
When it happens
Trigger: Legacy resolver ('--use-feature=no use of new resolver' off, or '--legacy-resolver') processing a distribution whose .dist-info/METADATA is missing from the index/cache, or whose extracted source has no metadata file. dist.requires_python access triggers FileNotFoundError.
Common situations: Corrupted pip cache; partially-downloaded distribution; a malformed package on an index; filesystem issue removing the metadata file; an old sdist that fails to generate metadata.
Related errors
- {path} is a symlink; Will not return uid for symlinks
- venv-creation-error
- Too many arguments
- Please provide a pattern
- Can not open an editor for a file name containing " {fname}
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/47a343b1a614ea51.json.
Report an issue: GitHub.