首页 > 解决方案 > How to solve ModuleNotFoundError: No module named 'tensorflow.python.eager'

问题描述

Hi I'm using TensorFlow on Linux with python 3.8.5, and I have upgraded the TensorFlow. But when I run the following code in the TensorFlow virtual environment

import tensorflow as tf
from tensorflow import keras

def get_dataset(training=True):
    mnist = keras.datasets.mnist
    #some code
    return something

It shows that

File "intro_keras.py", line 1, in <module>
import tensorflow as tf
File "/TensorFlow/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/TensorFlow/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 40, in <module>
from tensorflow.python.eager import context
ModuleNotFoundError: No module named 'tensorflow.python.eager'

How can I get rid of it? Thanks!

标签: pythontensorflowkerastensorflow2.0

解决方案


推荐阅读