Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

"AttributeError: type object 'Callable' has no attribute '_abc_registry'" always shows #34

Open
xybramble opened this issue Apr 8, 2021 · 3 comments

Comments

@xybramble
Copy link

xybramble commented Apr 8, 2021

I installed the packages mentioned here https://github.com/facebookresearch/TransCoder#dependencies
when I run

python translate.py --src_lang java --tgt_lang python --model_path trained_model.pth < all.java`  

It shows

Traceback (most recent call last):
  File "translate.py", line 22, in <module>
    import torch
  File "/opt/conda/lib/python3.7/site-packages/torch/__init__.py", line 280, in <module>
    from .functional import *
  File "/opt/conda/lib/python3.7/site-packages/torch/functional.py", line 2, in <module>
    import torch.nn.functional as F
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F401
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/__init__.py", line 2, in <module>
    from .linear import Identity, Linear, Bilinear
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 5, in <module>
    from .. import functional as F
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/functional.py", line 15, in <module>
    from .._jit_internal import boolean_dispatch, List
  File "/opt/conda/lib/python3.7/site-packages/torch/_jit_internal.py", line 257, in <module>
    import typing
  File "/home/jovyan/lib/python3/site-packages/typing.py", line 1359, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/home/jovyan/lib/python3/site-packages/typing.py", line 1007, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'

And no matter what I type on the command line, 'AttributeError: type object 'Callable' has no attribute '_abc_registry'' always shows.
According to the solutions metioned in google, I unintalled typing package by deleting typing.py because the same error shows when I use pip uninstall typing. The new error shows like this

Traceback (most recent call last):
  File "translate.py", line 24, in <module>
    import preprocessing.src.code_tokenizer as code_tokenizer
  File "/home/jovyan/TransCoder-master/preprocessing/src/code_tokenizer.py", line 21, in <module>
    from sacrebleu import tokenize_v14_international
ImportError: cannot import name 'tokenize_v14_international' from 'sacrebleu' (/home/jovyan/lib/python3/site-packages/sacrebleu/__init__.py)

Then I lower the version of sacrebleu (solution from google) then 'AttributeError: type object 'Callable' has no attribute '_abc_registry'' shows...

I wonder how to solve this problem? Thx!

@baptisteroziere
Copy link
Contributor

Hi,
Did you make sure to install the right version of sacrebleu with this command pip install sacrebleu=="1.2.11" ?

@xybramble
Copy link
Author

Hi,
Did you make sure to install the right version of sacrebleu with this command pip install sacrebleu=="1.2.11" ?

Yes I installed 1.2.11 according to the https://github.com/facebookresearch/TransCoder#dependencies .

@baptisteroziere
Copy link
Contributor

ok this error appears if you use the wrong version of sacrebleu so it may be worth checking that you are using the right python environment and that you have the right version installed (check that your pip and python link to the same environment with which and do pip list | grep sacrebleu). Maybe try to reinstall sacrebleu.
You also said that you had some issues with typing. The version 3.6.4 works for me but I don't think that's causing the issue with sacrebleu.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants