Module 'tensorflow' has no attribute 'keras'

I’m trying to migrate my RLlib configuration from v1.13.0 to v2.2.0 in server-client mode, but when I run the server script and try to from ray.rllib.algorithms.dqn import DQNConfig an error is showed in “\ray\rllib\models\tf\”:

class Keras_FullyConnectedNetwork(tf.keras.Model if tf else object):
AttributeError: module 'tensorflow' has no attribute 'keras'

How can I fix it?

which version of tensorflow are you using?
try upgrading tensorflow , maybe it could solve your problem

I fix the error using an virtual environment. I read that tensorflow need to be run in an virtual environment and not in the default system environment to works well. So creating an venv in anaconda fix the issue.