question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better error message for missing RECORD file

See original GitHub issue

What’s the problem this feature will solve? According to PEP 627, the RECORD file is now optional and its absence indicates that a package should not be uninstalled/upgraded by pip or another tool that relies on its content (see the last paragraph in docs). In Fedora, when you install an RPM package without .dist-info/RECORD file and then you try to uninstall it via pip, you’ll get a traceback like this:

# pip uninstall django
Found existing installation: Django 3.0.7
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
    status = self.run(options, args)
  File "/usr/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py", line 89, in run
    uninstall_pathset = req.uninstall(
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 685, in uninstall
    uninstalled_pathset = UninstallPathSet.from_dist(dist)
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 535, in from_dist
    for path in uninstallation_paths(dist):
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 67, in unique
    for item in fn(*args, **kw):
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 85, in uninstallation_paths
    r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD')))
  File "/usr/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1432, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1420, in get_metadata
    value = self._get(path)
  File "/usr/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1616, in _get
    with open(path, 'rb') as stream:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.9/site-packages/Django-3.0.7.dist-info/RECORD'

Describe the solution you’d like It would be nice to produce a better error message for cases like the one described above. It’d be also nice to use .dist-info/INSTALLER file (if exists) to indicate which tool a user should use to work with the package. Note that the INSTALLER file is also optional according to the PEP.

Additional context PEP 627: https://www.python.org/dev/peps/pep-0627/ Related to: https://github.com/pypa/pip/issues/8156 Packaging docs: https://packaging.python.org/specifications/recording-installed-packages/

Cc: @hroncok

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
encukoucommented, Dec 2, 2020

Shouldn’t refusing to uninstall/upgrade a package with no RECORD be done in pip? I think pkg_resources.get_metadata_lines is very correct to report FileNotFoundError if the file is not found.

0reactions
hroncokcommented, May 5, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing records in excel - Power Platform Community - Microsoft
The result is included in an excel file. -I open the excel, but I can see only one record, the other one is...
Read more >
Error message about a missing physical file - SAS Communities
I have an error message that has completely stumped me. The pertinent chunk of code is shown below. The message states that a...
Read more >
"Data Missing" error message in Review window in Empower
SYMPTOMS: When any user on any client attempts to review data (in Review window), they see a "Data Missing" message in the chromatogram...
Read more >
Getting error message "One or more backup files are missing ...
My hard drive crashed and I had to get a new computer. Luckily I had backed up my Quicken data on an external...
Read more >
c# - Exception for missing data - Stack Overflow
Be more specific, such as XMLDataMissingException. Then you can give a meamingful message to user or log it. Share.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found