0

I'm getting an error when I import Keras into my Python environment:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 9
      6 import seaborn as sns
      7 import tensorflow as tf
----> 9 from tensorflow.keras import layers
     10 from tensorflow.keras import models
     11 from IPython import display

ModuleNotFoundError: No module named 'tensorflow.keras'

Here are things I have tried:

  • Tensorflow is up to date

  • keras is up to date

  • Jupyter Notebook is apparently getting an update which is what I think the issue is

  • Seaborn, Matplotlib, Numpy all work

What could be the issue here? I tried using from tensorflow import keras and I got that error.

When I asked what version of tensorflow I have, it says this:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 print(tf.__version__)

AttributeError: module 'tensorflow' has no attribute '__version__'
khelwood
  • 55,782
  • 14
  • 81
  • 108
  • 2
    This kind of thing is often caused when you have named one of your own files `tensorflow.py`. Is that possible? – Tim Roberts May 16 '23 at 21:22
  • Does this answer your question? [How to import keras from tf.keras in Tensorflow?](https://stackoverflow.com/questions/47262955/how-to-import-keras-from-tf-keras-in-tensorflow) – ajgrinds May 16 '23 at 21:23
  • This isn't the issue. It's saying my tensorflow package is installed fine but it's not importing properly in jupyter. Refer to my comments below. There's some new information that could dissect the issue. – Wilson Beckman May 17 '23 at 16:14

1 Answers1

0

I ended up fixing the issue by deleting my anaconda navigator and redownloading it. I had to redownload essential coding libraries but that fixed the issue.