AttributeError: module 'tensorflow' has no attribute 'logging'. Did you mean: '_logging'?
时间: 2023-09-19 07:07:27 浏览: 62
This error occurs when a module in TensorFlow tries to access the attribute "logging" but it is not available. In recent versions of TensorFlow, the "logging" module has been moved to a separate package called "absl.logging".
To fix this error, you can replace any instances of "import tensorflow.logging" with "import absl.logging" and update any references to "tensorflow.logging" with "absl.logging".
For example:
```
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.INFO)
# should be replaced with:
import absl.logging as logging
logging.set_verbosity(logging.INFO)
```
相关问题
AttributeError: module 'logging' has no attribute 'getLogger'. Did you mean: 'Logger'?
这个错误通常是由于导入模块时出现问题导致的。'logging'模块是Python标准库中的一个模块,它提供了日志记录功能。根据你提供的错误信息,看起来是在使用'logging.getLogger()'方法时发生了错误。
可能的原因是你在代码中导入了一个名为'logging'的自定义模块或变量,覆盖了Python标准库中的'logging'模块。由于自定义模块或变量没有'getLogger()'方法,所以出现了该错误。
要解决这个问题,你可以尝试以下几个步骤:
1. 确保你没有在代码中导入一个名为'logging'的自定义模块或变量。如果有,请更改导入语句或重命名自定义模块/变量。
2. 检查你的Python环境是否正确安装并且没有损坏。你可以尝试重新安装Python或者在另外一个干净的Python环境中运行你的代码。
3. 确保你的代码中没有其他与'logging'模块相关的错误。有时候,其他错误可能会导致'getLogger()'方法无法正常工作。
希望这些步骤能够帮助你解决问题。如果还有其他问题,请随时提问!
AttributeError: module 'tensorflow' has no attribute 'logging'
从 TensorFlow 2.0 开始,`logging` 模块已被删除。要解决此问题,您可以将所有的 `import tensorflow.logging as logging` 替换为 `import logging`,并在代码中使用 `logging` 代替 `tensorflow.logging`。如果您的代码是从旧版本的 TensorFlow 中移植而来的,则需要进行相应的更新。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![CHM](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)