Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIP3 list failed completely and returing error

After I run "pip3 install rsa==3.4.2". I cannot use "pip3 list" command any more and pretty much any pip command will fail.

The error is like the following

Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2584, in version
    return self._version
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/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 "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_internal/cli/base_command.py", line 176, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_internal/commands/list.py", line 148, in run
    self.output_package_listing(packages, options)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_internal/commands/list.py", line 205, in output_package_listing
    data, header = format_for_columns(packages, options)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_internal/commands/list.py", line 271, in format_for_columns
    row = [proj.project_name, proj.version]
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/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] (/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages))

I don't have any clue so far. I wonder if there is an solution to this?

Thanks

like image 969
Henry Z Avatar asked Jan 28 '19 21:01

Henry Z


1 Answers

I had same issue and solved by following,

python3 -c "import site; print(site.getsitepackages())"

will list the location of site-packages,

['/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', '/Library/Python/3.6/site-packages']

and check the invalid directories,

cd /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
find . -name METADATA

for me ./-ip-18.1.dist-info/pip-18.1.dist-info/METADATA was the problem and I deleted the directory.

rm -rf ./-ip-18.1.dist-info

everything seems to be fine now.

like image 165
Tarık Yılmaz Avatar answered Oct 15 '22 01:10

Tarık Yılmaz