pypa/pip · error · UninstallMissingRecord
uninstall-no-record-file
uninstall-no-record-file
Error message
Cannot uninstall {distribution} What it means
UninstallMissingRecord (InstallationError subclass with code 'uninstall-no-record-file') raised by uninstallation_paths when the installed distribution has no RECORD file. RECORD (PEP 376/427) lists every file belonging to a dist; without it pip cannot enumerate what to remove and aborts. The error code lets tooling branch on this specific cause.
Source
Thrown at src/pip/_internal/req/req_uninstall.py:77
"""
Yield all the uninstallation paths for dist based on RECORD-without-.py[co]
Yield paths to all the files in RECORD. For each .py file in RECORD, add
the .pyc and .pyo in the same directory.
UninstallPathSet.add() takes care of the __pycache__ .py[co].
If RECORD is not found, raises an error,
with possible information from the INSTALLER file.
https://packaging.python.org/specifications/recording-installed-packages/
"""
location = dist.location
assert location is not None, "not installed"
entries = dist.iter_declared_entries()
if entries is None:
raise UninstallMissingRecord(distribution=dist)
for entry in entries:
path = os.path.join(location, entry)
yield path
if path.endswith(".py"):
dn, fn = os.path.split(path)
base = fn[:-3]
path = os.path.join(dn, base + ".pyc")
yield path
path = os.path.join(dn, base + ".pyo")
yield path
def compact(paths: Iterable[str]) -> set[str]:
"""Compact a path set to contain the minimal number of paths
necessary to contain all paths in the set. If /a/path/ and
/a/path/to/a/file.txt are both in the set, leave only the
shorter path."""View on GitHub (pinned to d7d0d0a394)
Solutions
- Reinstall the package with pip first ('pip install --force-reinstall <pkg>') so a proper RECORD is written, then 'pip uninstall <pkg>'.
- If the package was installed by your OS package manager, remove it via that manager (apt/dnf/etc.) instead of pip.
- Manually locate and remove the .dist-info directory and the package files, then verify with 'pip list'.
- Avoid 'python setup.py install' going forward; use 'pip install .'.
Example fix
# before pip uninstall foo # UninstallMissingRecord # after pip install --force-reinstall foo && pip uninstall foo
Defensive patterns
Strategy: try-catch
Validate before calling
def has_record(dist_info_dir: str) -> bool:
import os
return os.path.isfile(os.path.join(dist_info_dir, 'RECORD')) Type guard
def is_pip_uninstallable(dist) -> bool:
return dist.iter_declared_entries() is not None Try / catch
from pip._internal.exceptions import UninstallMissingRecord
try:
run_pip(['uninstall', '-y', 'pkg'])
except UninstallMissingRecord:
run_pip(['install', '--force-reinstall', '--no-deps', 'pkg'])
run_pip(['uninstall', '-y', 'pkg']) Prevention
- Install everything via pip so RECORD is always written.
- Avoid 'python setup.py install' and OS-package Python wheels you later want pip to remove.
- Before uninstall, check the .dist-info has a RECORD file.
When it happens
Trigger: Running 'pip uninstall <pkg>' where <pkg>'s .dist-info directory has no RECORD (dist.iter_declared_entries() returns None). Common for packages installed by non-pip tools or older installers that did not write RECORD.
Common situations: Distutils/easy_install installs; OS-packaged Python wheels installed by the system package manager; packages installed with 'python setup.py install' (legacy); manually copied-in distributions.
Related errors
- uninstall-distutils-installed-package
- You must give at least one requirement to {self.name} (see "
- <dynamic: upload-time missing detail>
- Bad metadata in {dist} (invalid metadata entry 'name')
- Error decoding metadata for {wheel}: {e} in {filename} file
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/34e7d11bea8bf4c7.json.
Report an issue: GitHub.