Pip: KeyError: 'pip._vendor.urllib3.util.queue' on any pip command

Created on 21 Jun 2018  路  7Comments  路  Source: pypa/pip

Environment

  • pip version: 10.0.1
  • Python version: 3.6
  • OS: Manjaro Linux

Description
On any pip command, even on simply calling pip --help I get this:

Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.6/site-packages/pip/_internal/__init__.py", line 20, in <module>
    from pip._vendor.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3.6/site-packages/pip/_vendor/__init__.py", line 82, in <module>
    vendored("requests.packages")
  File "/usr/lib/python3.6/site-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(vendored_name, globals(), locals(), level=0)
  File "/usr/lib/python3.6/site-packages/pip/_vendor/requests/packages.py", line 12, in <module>
    sys.modules['pip._vendor.requests.packages.' + mod] = sys.modules["pip._vendor." + mod]
KeyError: 'pip._vendor.urllib3.util.queue'
auto-locked

Most helpful comment

Yes, it appears to be some sort of distro-based problem. Simply reinstalling pip didn't help, but

rm -r /usr/lib/python3.6/site-packages/pip;
pacman -S python-pip --force

solved it for me. Got the idea from those two reports [1] [2].

All 7 comments

It seems to me that this _might_ be a vendoring issue from the distro's end. How did you install pip 10.0.1?

$ pacman -S python-pip about a year ago, it then survived multiple system upgrades. Not sure at which point it got broken, haven't used pip for awhile.

I'd suggest trying to (re?)install the latest version that your distro provides.

If pip's still broken after that, could you please report it to the distro (and link them to this issue and vice versa)?

Yes, it appears to be some sort of distro-based problem. Simply reinstalling pip didn't help, but

rm -r /usr/lib/python3.6/site-packages/pip;
pacman -S python-pip --force

solved it for me. Got the idea from those two reports [1] [2].

@Artalus how to do it in windows??
I have windows 7.

@hemangjoshi37a I do not have acces to Windows right now, but AFAIK you can find site-packages in either your Python installation (like C:/Python3.6/pip) or somewhere in C:/Users/<user> (likely in AppData).

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)
ImportError: 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.5/runpy.py", line 174, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.5/runpy.py", line 133, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.5/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 13, in
from pip.exceptions import InstallationError, CommandError, PipError
File "/usr/lib/python3/dist-packages/pip/exceptions.py", line 6, in
from pip._vendor.six import iteritems
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 75, in
vendored("pkg_resources")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 664, in _load_unlocked
File "", line 634, in _load_backward_compatible
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2927, in
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2913, in _call_aside
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, 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 956, in subscribe
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2515, in activate
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2097, in declare_namespace
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2047, in _handle_ns
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'

help me in this

Was this page helpful?
0 / 5 - 0 ratings