Broken pip: AttributeError: type object 'Callable' has no attribute '_abc_registry'

Viewed 725

as the title said, I get the error AttributeError: type object 'Callable' has no attribute '_abc_registry' with pip. In particular, i've seen the question AttributeError: type object 'Callable' has no attribute '_abc_registry' but the only answer does not work for me. In fact, i get:

> pip uninstall typing
Traceback (most recent call last):
  File "/home/user/.local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/home/user/.local/lib/python3.7/site-packages/pip/__init__.py", line 1, in <module>
    from typing import List, Optional
  File "/home/user/.local/lib/python3.7/site-packages/typing.py", line 1359, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/home/user/.local/lib/python3.7/site-packages/typing.py", line 1007, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry

So I've tried to downgrade pip, but i still get the same error

> python3 -m pip install pip==20.0.2
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/user/.local/lib/python3.7/site-packages/pip/__init__.py", line 1, in <module>
    from typing import List, Optional
  File "/home/user/.local/lib/python3.7/site-packages/typing.py", line 1359, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/home/user/.local/lib/python3.7/site-packages/typing.py", line 1007, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'

Same error when i ask for the pip version:

> pip --version
Traceback (most recent call last):
  File "/home/user/.local/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
  File "/home/user/.local/lib/python3.7/site-packages/pip/__init__.py", line 1, in <module>
    from typing import List, Optional
  File "/home/damiano/.local/lib/python3.7/site-packages/typing.py", line 1359, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/home/user/.local/lib/python3.7/site-packages/typing.py", line 1007, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'

In general, the whole pip seems broken. Even when i only type pip in the terminal I get the same error. Is there a way out? Thanks

1 Answers

I think that the problem here is that since Python 3.7 something has changed in the imports from the typing package.

A temporary solution, if viable, could be downgrading Python to 3.6.

As seen here: https://www.fernandomc.com/posts/issues-with-typing-python-3/

From what I can tell, the typing module was included as provisional part of the standard library as of Python 3.5. In versions 3.5.x and 3.6.x installing the typing module as a dependency didn’t cause any issues.

Recently, in Python 3.7 when it became a non-provisional part of the library the above issues with having pip-installed typing started to crop up.

Related issues:

Related