Tensorflow problem on windows 7


Using Windows 7

I have installed tensorflow using : “pip install tensorflow --upgrade”, and the “pip list” shows version 2.12.0, at the Pycharm I ran “import tensorflow as tf” without an error, but when I try to use tf.keras.models.Sequential() I get

ModuleNotFoundError: No module named ‘tensorflow.keras’

Even : tf.–version–


AttributeError: module ‘tensorflow’ has no attribute ‘version

Please advise

Algo (Removed by moderator)


Welcome to the Tensorflow Forum!

AttributeError: module ‘tensorflow’ has no attribute ‘version’

It suggests that Tensorflow is not properly installed or loaded in your Python environment.

Make sure that Tensorflow is properly installed in your python environment. You can check the installation by running the following command in your python environment:

import tensorflow as tf

If the issue still persists please uninstall and install fresh tensorflow in a virtual environment. For more details please refer to Instale o TensorFlow com pip.

In the latest version, you can use tf.keras.Sequential instead of tf.keras.models.Sequential.

Thank you!

In addition to the answer answer above, in case you’ve upgraded TensorFlow and it isn’t able to recognize tf.keras module, then you may need to totally remove/re-install Python, TensorFlow or start a new environment and install TensorFlow to it.