Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip list should not crash on a corrupted install #6283

Open
nbecker opened this issue Feb 21, 2019 · 7 comments
Open

pip list should not crash on a corrupted install #6283

nbecker opened this issue Feb 21, 2019 · 7 comments
Labels
type: bug A confirmed bug or unintended behavior

Comments

@nbecker
Copy link

nbecker commented Feb 21, 2019

Environment

  • pip version: 19.0.3
  • Python version: 3.7.2
  • OS: Fedora 29 linux

Description

 pip list
Exception:
Traceback (most recent call last):
  File "/home/nbecker/.local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2584, in version
    return self._version
  File "/home/nbecker/.local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__
    raise AttributeError(attr)
AttributeError: _version

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nbecker/.local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 179, in main
    status = self.run(options, args)
  File "/home/nbecker/.local/lib/python3.7/site-packages/pip/_internal/commands/list.py", line 148, in run
    self.output_package_listing(packages, options)
  File "/home/nbecker/.local/lib/python3.7/site-packages/pip/_internal/commands/list.py", line 205, in output_package_listing
    data, header = format_for_columns(packages, options)
  File "/home/nbecker/.local/lib/python3.7/site-packages/pip/_internal/commands/list.py", line 271, in format_for_columns
    row = [proj.project_name, proj.version]
  File "/home/nbecker/.local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2589, in version
    raise ValueError(tmpl % self.PKG_INFO, self)
ValueError: ("Missing 'Version:' header and/or METADATA file", Unknown [unknown version] (/home/nbecker/.local/lib/python3.7/site-packages))

Expected behavior

How to Reproduce

  1. Get package from '...'
  2. Then run '...'
  3. An error occurs.

Output

Paste the output of the steps above, including the commands themselves and
pip's output/traceback etc.
@cjerdonek
Copy link
Member

cjerdonek commented Feb 21, 2019

This looks like a duplicate of is related to #6177. To fix the issue in your case, can you paste in the contents of the site-packages directory shown in the last line of the error message?

@nbecker
Copy link
Author

nbecker commented Feb 21, 2019

Problem is, it didn't tell me what directory caused the problem! Turns out, by inspection of site-packages I quickly saw a corrupted installation and removed it.

@cjerdonek
Copy link
Member

Yes, that is the subject of the following issue and why I told you to list the contents of site-packages:
pypa/setuptools#1664
The issue is also mentioned in the comments to #6177.

Glad you were able to fix it. Can you tell us what the corruption was?

@cjerdonek cjerdonek changed the title pip list error pip list should not crash on a corrupted install Feb 21, 2019
@cjerdonek cjerdonek added the type: bug A confirmed bug or unintended behavior label Feb 22, 2019
@cjerdonek
Copy link
Member

Related to this issue, I filed a PR on setuptools' tracker to make the ValueError include the path to the directory causing the issue: pypa/setuptools#1706

@shott92
Copy link

shott92 commented Feb 27, 2019

sorry, complete newb here, having the same error, how do i resolve?
please see my site packages list thanks
site packages dir.txt

pganssle pushed a commit to cjerdonek/setuptools that referenced this issue Mar 31, 2019
Related to pip's github issue pypa/pip#6194.

This has come up in pip's issue tracker (github) multiple times:

  - pypa/pip#6177
  - pypa/pip#6283
  - pypa/pip#6194
pganssle pushed a commit to cjerdonek/setuptools that referenced this issue Apr 3, 2019
Related to pip's github issue pypa/pip#6194.

This has come up in pip's issue tracker (github) multiple times:

  - pypa/pip#6177
  - pypa/pip#6283
  - pypa/pip#6194
@cjerdonek
Copy link
Member

FYI, setuptools just made a release (40.9.0) where the ValueError exception message now includes the path to the specific directory causing the problem: pypa/setuptools#1706 (comment)

@deveshks
Copy link
Contributor

deveshks commented May 2, 2020

I manually removed the METADATA files from one of the packages, and now the exception contains the path of the file where the METADATA would have been, after forcing pip to look for the file by replace https://github.com/pypa/pip/blob/master/src/pip/_vendor/pkg_resources/__init__.py#L2681 with raise AttributeError

$ pip list
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/devesh/pip/src/pip/_vendor/pkg_resources/__init__.py", line 2681, in version
    raise AttributeError
AttributeError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/devesh/pip/src/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/Users/devesh/pip/src/pip/_internal/commands/list.py", line 164, in run
    self.output_package_listing(packages, options)
  File "/Users/devesh/pip/src/pip/_internal/commands/list.py", line 231, in output_package_listing
    data, header = format_for_columns(packages, options)
  File "/Users/devesh/pip/src/pip/_internal/commands/list.py", line 279, in format_for_columns
    row = [proj.project_name, proj.version]
  File "/Users/devesh/pip/src/pip/_vendor/pkg_resources/__init__.py", line 2689, in version
    raise ValueError(msg, self)
ValueError: ("Missing 'Version:' header and/or METADATA file at path: /Users/devesh/pip/.env/lib/python3.8/site-packages/tox-3.14.6.dist-info/METADATA", tox [unknown version] (/Users/devesh/pip/.env/lib/python3.8/site-packages))

From the comments above, seems like providing the path of the missing/corrupt file would help debug this issue, and hence this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants