pypa/pip · error · Exception

No .dist-info folder found in wheel

Error message

No .dist-info folder found in wheel

What it means

When pyproject_hooks falls back to extracting metadata from a built wheel (_get_wheel_metadata_from_wheel), _dist_info_files scans the wheel zip for a '<name>-<version>.dist-info/' folder. If none is found it raises a bare Exception('No .dist-info folder found in wheel'), indicating the produced wheel is malformed.

Source

Thrown at src/pip/_vendor/pyproject_hooks/_in_process/_in_process.py:224

                whl_basename, metadata_directory, config_settings
            )
    else:
        return hook(metadata_directory, config_settings)


WHEEL_BUILT_MARKER = "PYPROJECT_HOOKS_ALREADY_BUILT_WHEEL"


def _dist_info_files(whl_zip):
    """Identify the .dist-info folder inside a wheel ZipFile."""
    res = []
    for path in whl_zip.namelist():
        m = re.match(r"[^/\\]+-[^/\\]+\.dist-info/", path)
        if m:
            res.append(path)
    if res:
        return res
    raise Exception("No .dist-info folder found in wheel")


def _get_wheel_metadata_from_wheel(whl_basename, metadata_directory, config_settings):
    """Extract the metadata from a wheel.

    Fallback for when the build backend does not
    define the 'get_wheel_metadata' hook.
    """
    from zipfile import ZipFile

    with open(os.path.join(metadata_directory, WHEEL_BUILT_MARKER), "wb"):
        pass  # Touch marker file

    whl_file = os.path.join(metadata_directory, whl_basename)
    with ZipFile(whl_file) as zipf:
        dist_info = _dist_info_files(zipf)
        zipf.extractall(path=metadata_directory, members=dist_info)
    return dist_info[0].split("/")[0]

View on GitHub (pinned to d7d0d0a394)

Solutions

  1. Report/fix the backend so its built wheel includes a proper <name>-<version>.dist-info directory with METADATA.
  2. Upgrade or switch to a spec-compliant backend (setuptools, hatchling, flit).
  3. Rebuild cleanly to rule out a corrupt intermediate wheel; clear any build cache.
Defensive patterns

Strategy: validation

Validate before calling

import zipfile, re
with zipfile.ZipFile(wheel_path) as z:
    if not any(re.match(r'[^/\\]+-[^/\\]+\.dist-info/', n) for n in z.namelist()):
        raise ValueError('wheel is missing a .dist-info folder')

Try / catch

try:
    meta = _get_wheel_metadata_from_wheel(basename, md_dir, cfg)
except Exception as e:
    if 'No .dist-info' in str(e):
        log.error('backend produced a non-compliant wheel: %s', e)
    raise

Prevention

When it happens

Trigger: prepare_metadata_for_build_wheel is unsupported by the backend, so a wheel is built and its .dist-info extracted; the backend produced a wheel with no dist-info directory (violating the wheel spec). Also reachable if the wheel file is corrupt or truncated so the zip listing omits the folder.

Common situations: A buggy or non-compliant build backend that omits dist-info; a wheel assembled by hand or a custom backend that forgets METADATA; filesystem/zip corruption during the build.

Related errors


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/e73217d194620540.json. Report an issue: GitHub.