tensorflow 报错: AttributeError: module 'tensorflow' has no attribute 'xxxx'

今天在运行程序的时候出现了题目的这个问题,通过查询网上共有以下几种方案,记录下来,分享给更多遇到同样问题的培养。

  1. TensorFlow新版本修改了许多函数的名字,不完全整理如下:

    tf.sub()更改为tf.subtract()
    tf.mul()更改为tf.multiply()
    tf.types.float32更改为tf.float32
    tf.pact()更改为tf.stact()

  2. 项目中的文件名命名为tensorflow.py
    这种情况是最简单的情况,只需要修改文件名即可。

  3. 安装的tensorflow是个空包
    这个问题需要将tensorflow卸载,再重新安装
    卸载代码是:

pip uninstall tensorflow

重新安装可以代码是

pip install tensorflow==2.0 

如果直接安装太慢可以利用清华大学的镜像,这个镜像在安装其他包时同样可以使用

-i https://pypi.tuna
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AttributeError: module 'itasca' has no attribute 'command'错误是因为你在itasca模块中使用了一个名为command的属性,但该属性在该模块中不存在。 要解决这个问题,你可以尝试以下方法: 1. 检查itasca模块是否正确安装:首先确保你已经正确安装了itasca模块。可以通过运行pip install itasca来安装该模块。如果已经安装了该模块,可以尝试升级到最新版本,以确保没有版本兼容性问题。 2. 检查命令的拼写和大小写:确认你正在使用的命令名字的拼写和大小写是否与itasca模块中定义的一致。因为Python是区分大小写的,所以命令名必须精确匹配。 如果以上两个方法都没有解决问题,那么可能是itasca模块本身就没有定义名为command的属性。在这种情况下,你需要查阅itasca模块的文档或者联系该模块的开发者来获取更多帮助。 另外,如果你在代码中引用了itasca模块但没有导入它,你需要添加import itasca语句来导入该模块。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [AttributeError: module 'tensorflow.compat.v1' has no attribute '](https://download.csdn.net/download/qq_38766019/86272235)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Python异常:AttributeError: modulexxxx‘ has no attribute ‘open‘ 解决办法](https://blog.csdn.net/weixin_44259720/article/details/126744651)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [关于python:AttributeError: module 'xxx' has no attribute 'xxx'的错误解决](https://blog.csdn.net/weixin_35737303/article/details/80203586)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值