ImportError: cannot import name 'AutoModel' from 'transformers'
See original GitHub issue🐛 Bug
(Not sure that it is a bug, but it is too easy to reproduce I think)
Information
I couldn’t run python -c 'from transformers import AutoModel'
, instead getting the error on the titile.
To reproduce
Steps to reproduce the behavior:
$ sudo docker run -it --rm python:3.6 bash
# pip install tensorflow==2.0 transformers==2.8.0
# python -c 'from transformers import AutoModel'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'AutoModel'
Initially I got this error with transformers-cli download
:
# transformers-cli download t5-large
Traceback (most recent call last):
File "/usr/local/bin/transformers-cli", line 32, in <module>
service.run()
File "/usr/local/lib/python3.6/site-packages/transformers/commands/download.py", line 29, in run
from transformers import AutoModel, AutoTokenizer
ImportError: cannot import name 'AutoModel'
Expected behavior
no import error.
Environment info
transformers
version: 2.8.0- Platform: Linux-4.15.0-99-generic-x86_64-with-debian-10.3
- Python version: 3.6.10
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.0.0 (False)
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no
Also tested on 3.6@Ubuntu 18.04, 3.8@Docker(python:3.8). The Docker backend is Ubuntu 18.04.
Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
ImportError: cannot import name 'AutoModelWithLMHead ...
This is literally all the code that I am trying to run: from transformers import ...
Read more >How to resolve the hugging face error ImportError: cannot ...
I was trying to use the ViTT transfomer. I got the following error with code: from pathlib import Path import torchvision from typing...
Read more >cannot import name 'TFAutoModel' from 'transformers'
ImportError : cannot import name 'TFAutoModel' from 'transformers'. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On May 29, ......
Read more >importerror: cannot import name 'contextapi' from 'docker'
I couldn't run python -c 'from transformers import AutoModel' , instead getting the error on the titile. To reproduce. Steps to reproduce the...
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
AutoModel
is the equivalent ofTFAutoModel
but for PyTorch model classes. If you don’t have pytorch installed this is expected.Use
TFAutoModel
instead =)EDIT: Well… This issue has been solved by updating dependencies but now it produces another issue. I will post the link to the reproducible issue in a minute.