Can’t Import BertTokenizer

I am attempting to use the BertTokenizer part of the transformers package. First I install as below.

pip install transformers

Which says it succeeds.

When I try to import parts of the package as below I get the following.

 from transformers import BertTokenizer
Traceback (most recent call last):

  File "<ipython-input-2-89505a24ece6>", line 1, in <module>
    from transformers import BertTokenizer

  File "C:\Users\User\anaconda3\lib\site-packages\transformers\__init__.py", line 22, in <module>
    from .integrations import (  # isort:skip

  File "C:\Users\User\anaconda3\lib\site-packages\transformers\integrations.py", line 42, in <module>
    from .trainer_utils import PREFIX_CHECKPOINT_DIR, BestRun  # isort:skip

  File "C:\Users\User\anaconda3\lib\site-packages\transformers\trainer_utils.py", line 10, in <module>
    from .tokenization_utils_base import ExplicitEnum

  File "C:\Users\User\anaconda3\lib\site-packages\transformers\tokenization_utils_base.py", line 31, in <module>
    from tokenizers import AddedToken

  File "C:\Users\User\anaconda3\lib\site-packages\tokenizers\__init__.py", line 17, in <module>
    from .tokenizers import Tokenizer, Encoding, AddedToken

ModuleNotFoundError: No module named 'tokenizers.tokenizers'

The package is detailed here so I think it should be available https://huggingface.co/transformers/model_doc/bert.html



Read more here: https://stackoverflow.com/questions/64406166/cant-import-berttokenizer

Content Attribution

This content was originally published by user2355903 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: