question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: No module named 'transformers.tokenization_bert'

See original GitHub issue

Hello. I am getting an error. I was using the Sentiment analysis notebook on colab by NVIDIA NeMo I followed the instructions as it said(run the first cell if you are on colab and vice versa). In the second cell, it is said that restart runtime after running it. After restarting kernal, (or even if I don’t) I am getting this error: ModuleNotFoundError: No module named 'transformers.tokenization_bert'. It is from the first import of the 3rd cell, from nemo.collections import nlp as nemo_nlp

The full traceback is:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-6-9dea72b2f46b> in <module>()
----> 1 from nemo.collections import nlp as nemo_nlp
      2 from nemo.utils.exp_manager import exp_manager
      3 
      4 import os
      5 import wget

3 frames
/usr/local/lib/python3.6/dist-packages/nemo/collections/nlp/__init__.py in <module>()
     13 # limitations under the License.
     14 
---> 15 from nemo.collections.nlp import data, models, modules
     16 from nemo.package_info import __version__
     17 

/usr/local/lib/python3.6/dist-packages/nemo/collections/nlp/data/__init__.py in <module>()
     25     NeuralMachineTranslationDataset,
     26 )
---> 27 from nemo.collections.nlp.data.question_answering_squad.qa_dataset import SquadDataset
     28 from nemo.collections.nlp.data.token_classification.token_classification_dataset import (
     29     BertTokenClassificationDataset,

/usr/local/lib/python3.6/dist-packages/nemo/collections/nlp/data/question_answering_squad/qa_dataset.py in <module>()
     26 
     27 from nemo.collections.common.parts.utils import _compute_softmax
---> 28 from nemo.collections.nlp.data.question_answering_squad.qa_squad_processing import (
     29     EVALUATION_MODE,
     30     INFERENCE_MODE,

/usr/local/lib/python3.6/dist-packages/nemo/collections/nlp/data/question_answering_squad/qa_squad_processing.py in <module>()
     20 
     21 from tqdm import tqdm
---> 22 from transformers.tokenization_bert import BasicTokenizer
     23 
     24 from nemo.collections.nlp.data.data_utils import DataProcessor, is_whitespace, normalize_answer

ModuleNotFoundError: No module named 'transformers.tokenization_bert'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

I tried searching stack overflow, but it didn’t helped. And I don’t want to tinker the main NeMo module myself cause I don’t know what might go wrong if I change something. What shall I do?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
mattchurgincommented, Dec 16, 2020

It looks like the latest version of transformers (4.0.1) is being installed. I reverted to 3.5, and the code works. Before importing nemo.collections, run the following and it should work:

!pip uninstall transformers
!pip install transformers==3.5
1reaction
lvjiujincommented, Dec 18, 2020

I think we’d better use the new version to solve the problem , not to always use the older version 3.5 tranformers to solve it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named 'transformers.models' while trying to import ...
I am trying to import BertTokenizer from the transformers ...
Read more >
modulenotfounderror: no module named 'transformers' ( Solved )
The solution for this no module named 'transformers' is very simple. You have to just install transformers on your system. To install it...
Read more >
No module named 'transformers' - Python | bobbyhadz
The Python "ModuleNotFoundError: No module named 'transformers'" occurs when we forget to install the transformers module before importing ...
Read more >
Source code for transformers.tokenization_auto - Hugging Face
A path to a `directory` containing vocabulary files required by the tokenizer, for instance saved using the :func:`~transformers.
Read more >
no module named 'transformers.activations' - You.com | The AI ...
The Python ModuleNotFoundError: No module named 'transformers' occurs when we forget to install the `transformers` module before importing it or install it in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found