RuntimeError: Failed to import transformers.models.roberta.modeling_tf_roberta because of the following error (look up to see its traceback): No module named 'keras.engine'

Hi,

I wrote very small code :
from transformers import pipeline
model_id = “cardiffnlp/twitter-roberta-base-sentiment-latest”
sentiment_pipe = pipeline(“sentiment-analysis”, model=model_id)
print(sentiment_pipe(‘We hope you dont hate it’))
ERROR - RuntimeError: Failed to import transformers.models.roberta.modeling_tf_roberta because of the following error (look up to see its traceback):
No module named ‘keras.engine’
I tried to install tensorflow == 2.10 but its not present

Issue here:
File ~\AppData\Local\anaconda3\Lib\site-packages\transformers\modeling_tf_utils.py:69
68 from keras import backend as K
—> 69 from keras.engine import data_adapter
70 from keras.engine.keras_tensor import KerasTensor

ModuleNotFoundError: No module named ‘keras.engine’

Solutions: change the line 69 and 70 to ‘from tensorflow.python.keras.engine import data_adapter’ and ‘from tensorflow.python.keras.engine.keras_tensor import KerasTensor’

Thanks alot for the help