Tensorflow导入成功使用却失效(AttributeError: module ‘tensorflow’ has no attribute ‘xxx_’)
【错误信息】
AttributeError: module 'tensorflow' has no attribute 'xxx_'
【解决1】
重装
pip uninstall tensorflow
pip install tensorflow
其中若报类似raise ReadTimeoutErrorself._pool, None, ‘Read timed out.’
的超时错误,需要用国内镜像源进行安装:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ tensorflow
【解决2】
将import tensorflow
改为import tensorflow.compat.v1 as tf