pip: `ModuleNotFoundError: No module named 'pip._vendor.pkg_resources'` AND `AttributeError: '_NamespacePath' object has no attribute 'sort'`
- Pip version: I believe it is 8.1.2
- Python version: 3.6.0
- Operating system: Ubuntu Server 16.10 (x64)
Description:
Pip errors whenever I use the command. It doesn’t matter which command. python3.6 -m pip
errors.
What I’ve run:
logandark@LD-Server:~$ python3.6 -m pip
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ModuleNotFoundError: No module named 'pip._vendor.pkg_resources'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 75, in <module>
vendored("pkg_resources")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2976, in <module>
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2962, in _call_aside
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 3004, in _initialize_master_working_set
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2535, in activate
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2109, in declare_namespace
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2058, in _handle_ns
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2078, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (5 by maintainers)
I had this issue on Arch and fixed it with:
Closing as duplicate of #4216. It should be fixed in master (
pip install -I https://github.com/pypa/pip/archive/master.zip#egg=pip
to test).So after using pip as root and seeing it working, I knew the erroneous package was in my
~/.local/lib/python3.6/site-packages
. Here’s what fixed it for me:rm -rf ~/.local/lib/python3.6/site-packages/*
I’m not kidding either. I might also try reinstalling every package from a previous
ls
listing one by one to see which one caused the problem. I’m feeling lazy right now :pOne suggested solution on Anaconda3 in windows 10:
conda uninstall pip
conda install -c anaconda pip
@itay-grudev sometimes
sudo pacman -Syu python-pip --force