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:
- Created 3 years ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
You are correct, and that was a mistake on my part.
Thanks!