Click here to Skip to main content
15,848,415 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried the following code:

Python
import torch
from transformers import PegasusForConditionalGeneration, PegasusTokenizer

But it gives me the following output:
2022-01-31 11:12:51.303973: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
Traceback (most recent call last):
  File "text_paraphraser.py", line 20, in <module>
    from transformers import PegasusForConditionalGeneration, PegasusTokenizer
ImportError: cannot import name 'PegasusForConditionalGeneration' from 'transformers' (E:\Programming\envs\ANNA\lib\site-packages\transformers\__init__.py)

This is all in a Anaconda Prompt in an environmenf it that helps.

What I have tried:

Following multiple tutorials from multiple places, i thought something was wrong with how i was using the Pegasus transformer but seems that it was actually at the import step everything went sideways.
Posted
Comments
Richard MacCutchan 31-Jan-22 5:53am    
The message suggests that the import is not available in your transformers installation. You should manually check that it has been installed properly, and is the correct version.
Richard MacCutchan 31-Jan-22 8:09am    
I had a look at the Pegasus website and they recommend installing in a Python virtual environment. That is something you should definitely try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900