I’m currently working on a project in PyCharm and I’m having trouble importing tensorflow.keras. It seems like the keras module is not recognized by the PyCharm editor. The error message indicates that the postfix keras is not recognized, and it appears that the keras module is located inside the python folder rather than directly in the tensorflow directory. tf.version is 2.12.0.
I have tried the following steps to resolve the issue, but none have worked:
Reinstalled TensorFlow:
pip uninstall tensorflow
pip install tensorflow
Checked TensorFlow Version:
Verified the Environment:
import tensorflow as tf
print(tf.__version__)
Made sure that the correct virtual environment is activated.
Ensured that TensorFlow is installed in the correct environment.
Manually Checked Module Locations:
Noted that keras is inside the python folder instead of directly in the tensorflow directory.
I can use the python prefix before calling keras, on the other hand, that is not conventional and requires me to disable the eager execution. Has anyone faced a similar issue? How can I fix this so that tensorflow.keras is recognized correctly? Any updates from tensorflow which I should be aware of? My issue is on py-charm, jupyter-lab works fine. Or should I install any other packages from tensorflow associated with the module Keras.