module 'tensorflow' has no attribute '_version_'

研究生的奇妙冒险仍在继续。在论(lao)文(ban)的需求下,学习入门TensorFlow,配置环境第一关就扑街。按照官方文档中的教程,在运行第二行代码print(tf._version_)的时候遇到了

AttributeError: module 'tensorflow' has no attribute '_version_'

寻找解决方案,尝试了一下方法:1、重装大法;2、重新创建虚拟环境;3、使用import tensorflow.compat.v1 as tf

全部扑街。

心灰意冷之际重新copy了文档中的源码去运行(因为在学习嘛,大部分代码都想自己敲一遍,之前就没有直接copy),居然成功了???

仔细对比发现,问题出在“_”这个东西上面

>>> print(tf.__version__)
2.1.0

这是文档里的

>>> tf._version_
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute '_version_'

这是我的

可以看出,两者长度不一致,前者明显长一些,真是bug原因之多,无奇不有。吃一堑长一智。

  • 49
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 30
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 30
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值