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.

Colab ModuleNotFoundError 'transformers.modeling_albert' when importing

See original GitHub issue

**Describe the compatibility issue **

My code has been working fine for about the past month, but today it seems today something was updated and now I’m getting this error when importing ClassificationModel

To Reproduce

Run these two lines of code in a cell:

!pip install --upgrade transformers
!pip install  simpletransformers

(Should ask you to Restart Runtime, which I do.)

In another cell run: from simpletransformers.classification import ClassificationModel

and you will get the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-5-7d71e4d443ca> in <module>()
----> 1 from simpletransformers.classification import ClassificationModel
      2 import pandas as pd
      3 import logging

2 frames
/usr/local/lib/python3.6/dist-packages/simpletransformers/classification/__init__.py in <module>()
----> 1 from simpletransformers.classification.classification_model import ClassificationModel
      2 from simpletransformers.classification.multi_label_classification_model import MultiLabelClassificationModel
      3 from simpletransformers.classification.multi_modal_classification_model import MultiModalClassificationModel
      4 from simpletransformers.config.model_args import (
      5     ClassificationArgs,

/usr/local/lib/python3.6/dist-packages/simpletransformers/classification/classification_model.py in <module>()
     72     convert_examples_to_features,
     73 )
---> 74 from simpletransformers.classification.transformer_models.albert_model import AlbertForSequenceClassification
     75 from simpletransformers.classification.transformer_models.bert_model import BertForSequenceClassification
     76 from simpletransformers.classification.transformer_models.camembert_model import CamembertForSequenceClassification

/usr/local/lib/python3.6/dist-packages/simpletransformers/classification/transformer_models/albert_model.py in <module>()
      2 import torch.nn as nn
      3 from torch.nn import CrossEntropyLoss, MSELoss
----> 4 from transformers.modeling_albert import AlbertConfig, AlbertModel, AlbertPreTrainedModel
      5 
      6 

ModuleNotFoundError: No module named 'transformers.modeling_albert'

---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------

Additional Context

Settings for Runtime are: Hardware Accelerator: GPU Memory: High-Ram

Edit: Changed ‘bug’ to ‘compatibility issue’

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
Mathufnncommented, Nov 30, 2020

Same happened to me @pop-ketle .

The Transformers library just updated to 4.0.0 today and introduced some breaking changes. So I tried downgrading to the previous version (3.5.1) and it worked. This is a compatibility issue.

0reactions
rambleRamblePiecommented, Dec 1, 2020

You are correct, and that was a mistake on my part.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named 'transformers' on Google Colab · Issue #6347
I installed transformers using the command !pip install transformers on Google Colab Notebook But then I try to import transformers it ...
Read more >
ModuleNotFoundError: no module named 'transformers'
Probably it is because you have not installed in your (new, since you've upgraded to colabs pro) session the library transformers.
Read more >
modulenotfounderror: no module named 'transformers' ( Solved )
You can see there is a red line below the import statement. It tells you that the Transformers is not installed. When you...
Read more >
ModuleNotFoundError: No module named 'transformers'
Hi! I've been having trouble getting transformers to work in Spaces. When tested in my environment using python -c "from transformers import ......
Read more >
no module named 'transformers.activations' - You.com | The AI ...
when type "import torch" in jupyter notebook i get the following. ModuleNotFoundError Traceback (most recent call last) in () ----> 1 import torch....
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