pip: pip19.0.1 list error"AttributeError: _version"
Environment
- pip version:19.0.1
- Python version:3.7
- OS:MacOS
I update pip from 10.1 to 19.0.1, and I wanna check my python packages, I input “pip list” then two errors occurred. Description
Expected behavior
Exception: Traceback (most recent call last): File “/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/site-packages/pip/_vendor/pkg_resources/init.py”, line 2584, in version return self._version File “/usr/local/var/pyenv/versions/3.7.0/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 “/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/site-packages/pip/_internal/cli/base_command.py”, line 176, in main status = self.run(options, args) File “/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/site-packages/pip/_internal/commands/list.py”, line 148, in run self.output_package_listing(packages, options) File “/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/site-packages/pip/_internal/commands/list.py”, line 205, in output_package_listing data, header = format_for_columns(packages, options) File “/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/site-packages/pip/_internal/commands/list.py”, line 271, in format_for_columns row = [proj.project_name, proj.version] File “/usr/local/var/pyenv/versions/3.7.0/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] (/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/site-packages)) How to Reproduce
- Get package from ‘…’
- Then run ‘…’
- An error occurs.
Output
Paste the output of the steps above, including the commands themselves and
pip's output/traceback etc.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 32 (13 by maintainers)
Commits related to this issue
- Fixes #6194: Make failed uninstalls roll back more reliably and better at avoiding naming conflicts. — committed to zooba/pip by zooba 5 years ago
- Merge #1726 #1732 1726: Update python:3.7-slim Docker digest to 8a125f6 r=peterbe a=renovate[bot] This PR contains the following updates: | Package | Update | Change | |---|---|---| | python | dige... — committed to mozilla/normandy by bors[bot] 5 years ago
- Scheduled monthly dependency update for March (#23) ### Update [pip](https://pypi.org/project/pip) from **19.0.1** to **19.0.3**. <details> <summary>Changelog</summary> ##... — committed to vilkasgroup/Pakettikauppa by pyup-bot 5 years ago
- Include file path when Version: missing Related to pip's github issue pypa/pip#6194. — committed to cjerdonek/setuptools by cjerdonek 5 years ago
- Include file path when Version: missing 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/pi... — committed to cjerdonek/setuptools by cjerdonek 5 years ago
- Include file path when Version: missing 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/pi... — committed to cjerdonek/setuptools by cjerdonek 5 years ago
@AnonGuy thanks a lot 🙌🏼
-rpcio
with a dash was making the problem…Same for me a package with a dash was the culprit.
Did that: https://github.com/pypa/setuptools/issues/1664
To identify offending packages, I ran the following inside the site-packages directory:
Then removed the offending directories and reinstalled their packages.
These don’t look right…
Fixed by removing a folder called
-umpy-1.15.4.dist-info
fromsite-packages
.The cause for a lot of these was fixed in version 19.0.2, which is why this issue was closed. However, people might still be experiencing this issue because of directories that were corrupted before (or getting corrupted for a completely different reason). Subscribe to issue #6283 for more graceful handling of these directories, and for suggestions on how to remove a corrupted directory you might have.
yup thanks, i moved those and i had to also move pip itself but that fixed it it seems, could there be a bug in pip so that packages are put in the wrong folders? because i never moved anything around there
@0000matteo0000 Does this fix your issue?
I got the same problem in my mac. The original pip was installed along with python3 through
brew install python3
and works well. After i tried to update pip bypip3 install -U pip
, pip commands(pip list) start to raise those exceptions. The discussion above give me a hint to check whether broken project exists in my site-packages folder or not.pip --version
showspip 19.0.1 from /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip (python 3.6)
, i went into the folder and tried to find some folders starting with ‘-’ with no luck.then
pip list
outputs:I realized that broken packages may exist in
/Users/king/Library/Python/3.6/lib/python/site-packages
and it does in fact. After i remove broken packages in this folder, pip comes back to life!I am also getting some error using pip freeze. I am using windows 10, python 3.6.0 and pip version is 19.0.1. Please take a look:
Any help will be appreciated.