运行“ pip3 install rsa == 3.4.2”后。我不能再使用“ pip3 list”命令,几乎所有pip命令都会失败。
错误如下所示
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))
到目前为止,我没有任何线索。我想知道是否有解决方案?
谢谢
答案 0 :(得分:12)
我遇到了同样的问题,并通过以下方式解决了
python3 -c "import site; print(site.getsitepackages())"
将列出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']
并检查无效的目录,
cd /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
find . -name METADATA
对我来说./-ip-18.1.dist-info/pip-18.1.dist-info/METADATA
是问题所在,我删除了目录。
rm -rf ./-ip-18.1.dist-info
现在一切似乎都很好。