Valeria
Valeria

Reputation: 1210

AttributeError: module 'typing_extensions' has no attribute 'Protocol'

I am trying to run the following code: https://github.com/silviazuffi/smalst. However, I am using Python 3 instead of Python 2 because it does not seem to be possible to use Python 2 anymore with new CUDA drivers and due to the compatibility issues of some libraries used by that repo.

However, I am getting this error:

AttributeError: module 'typing_extensions' has no attribute 'Protocol'

Full traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/iegorval/Diploma/smalst/smal_eval.py", line 21, in <module>
    from .nnutils import smal_predictor as pred_util
  File "/home/iegorval/Diploma/smalst/nnutils/smal_predictor.py", line 22, in <module>
    from ..nnutils.nmr import NeuralRenderer
  File "/home/iegorval/Diploma/smalst/nnutils/nmr.py", line 9, in <module>
    import chainer
  File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/__init__.py", line 10, in <module>
    from chainer import backends  # NOQA
  File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/__init__.py", line 1, in <module>
    from chainer.backends import cuda  # NOQA
  File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/cuda.py", line 46, in <module>
    from chainer.backends import intel64
  File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/intel64.py", line 8, in <module>
    from chainer.configuration import config
  File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/configuration.py", line 5, in <module>
    from chainer import types  # NOQA
  File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/types.py", line 47, in <module>
    class AbstractInitializer(tpe.Protocol):
AttributeError: module 'typing_extensions' has no attribute 'Protocol'

So, it fails to detect Protocol in the typing_extensions module. However, I have installed typing-extensions==3.7.4.3 (https://pypi.org/project/typing-extensions/), and PyPi description seem to state that Protocol should be there.

Any idea how to fix this error?

Upvotes: 4

Views: 2992

Answers (0)

Related Questions