- AttributeError: module ‘tensorflow’ has no attribute ‘compat’ when importing tensorflow
问题详述:在利用 Anaconda 安装 tensorflow 2.1 后,运行时出现报错:AttributeError: module ‘tensorflow’ has no attribute ‘compat’ when importing tensorflow
,
分析后需要安装对应版本的tensorflow-estimator
通过pip show tensorflow
查看安装的Tensorflow版本,比如我是Tensorflow 2.1版本,就安装2.1版本的tensorflow-estimator
pip show tensorflow
conda install tensorflow-estimator==2.1
PS. 本来from tensorflow.keras import layers, Sequential
、from tensorflow.keras.datasets import imdb
这种操作是报错的,但是安装后,发现不报错了