'ModuleNotFoundError: No module named 'tensorflow.python.eager' when loading Sequential model

When attempting to import Sequential from keras.models, I get the error shown below. I have already uninstalled and reinstalled tensorflow through PIP, but am not sure what else I can do to fix this. Even though I was able to use Keras in the past, I'm not sure what could have messed this up.

I'm using Python 3.6.0 on MacOS x86_64 with Tensorflow 2.2.0 installed.

Thank you in advance for any help.


ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-55-9a7e0bd7095e> in <module>()
----> 1 from keras.models import Sequential
      2 from keras.layers import Conv2D, MaxPooling2D, Dropout, Flatten, Dense, Activation, BatchNormalization
      3 from keras.callbacks import EarlyStopping, ReduceLROnPlateau
      4 
      5 model = Sequential()

/Applications/anaconda3/lib/python3.6/site-packages/keras/__init__.py in <module>()
      1 from __future__ import absolute_import
      2 
----> 3 from . import utils
      4 from . import activations
      5 from . import applications

/Applications/anaconda3/lib/python3.6/site-packages/keras/utils/__init__.py in <module>()
      4 from . import data_utils
      5 from . import io_utils
----> 6 from . import conv_utils
      7 from . import losses_utils
      8 from . import metrics_utils

/Applications/anaconda3/lib/python3.6/site-packages/keras/utils/conv_utils.py in <module>()
      7 from six.moves import range
      8 import numpy as np
----> 9 from .. import backend as K
     10 
     11 

/Applications/anaconda3/lib/python3.6/site-packages/keras/backend/__init__.py in <module>()
----> 1 from .load_backend import epsilon
      2 from .load_backend import set_epsilon
      3 from .load_backend import floatx
      4 from .load_backend import set_floatx
      5 from .load_backend import cast_to_floatx

/Applications/anaconda3/lib/python3.6/site-packages/keras/backend/load_backend.py in <module>()
     88 elif _BACKEND == 'tensorflow':
     89     sys.stderr.write('Using TensorFlow backend.\n')
---> 90     from .tensorflow_backend import *
     91 else:
     92     # Try and load external backend.

/Applications/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in <module>()
      4 
      5 import tensorflow as tf
----> 6 from tensorflow.python.eager import context
      7 from tensorflow.python.framework import device as tfdev
      8 from tensorflow.python.framework import ops as tf_ops

ModuleNotFoundError: No module named 'tensorflow.python.eager'


Solution 1:[1]

Try this. You probably don't have the updated tensorflow.estimator package

pip uninstall tensorflow_estimator
pip install -Iv tensorflow_estimator==1.13.0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Edeki Okoh