0

I am trying to learn NLP using BERT. While trying to import bert model and tokenizer in colab. I am facing the below error.

ImportError: cannot import name '_LazyModule' from 'transformers.file_utils' (/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py)

Here is my code

!pip install transformers==4.11.3
from transformers import BertModel, BertTokenizer
import torch

In order to fix the error. I tried to upgrade both transformers and torch.

I have tried the solution from the below link:This

Still i am unable to go forward. Please assist.

mahesh mj
  • 15
  • 1
  • 5

1 Answers1

0

Based on these links 1, 2

This should help -

pip install 'lightning-flash[text]' --upgrade

Since the code provided by you is not the cause of the error as it runs on Colab when I tried it hence this might be the culprit in your environment

FoundABetterName
  • 103
  • 3
  • 18
  • 1
    Thank you, It appears to be the environment issue. I tried to run google colab in mozila browser instead of chrome. its working now. its unusual, but its working now. Thanks – mahesh mj Aug 15 '22 at 14:24