Pycharm problem with hub.keraslyer intransfer learning

below is my code, it’s running normally in google colab but it’s giving error in pycharm.
the code is:
import tensorflow as tf
import tensorflow_hub as hub
model_url = “mobilenet_v2 | Kaggle


the error is:
Only instances of keras.Layer can be added to a Sequential model

knowing that it’s runing normaly in google colab

the solution is to make sure that keras is version 2.something : Since TF2.16 comes with Keras3 the problem arises. As a workaround, we can install tf_keras package and set environment variable TF_USE_LEGACY_KERAS=1 to ensure Keras2 will be used with tf.keras.