1.ImportError: No module named PIL
解决办法:conda install Pillow
用网上说的解决办法:
(1)将import tensorflow as tf 改为import tensorflow.compat.v1 as tf
(2)用tf.compat.v1.flags替换tf.app.flags
都没用
最后把tensorflow先升级到2.0.0。pip install --upgrade tensorflow==2.0.0
再改成
import tensorflow.compat.v1 as tf
FLAGS = tf.app.flags.FLAGS
2.
AttributeError: 'module' object has no attribute 'set_keras_submodules'
- AttributeError: 'module' object has no attribute 'get_default_graph'
- AttributeError: 'Tensor' object has no attribute '_keras_shape'
都是keras和tensorflow的版本问题,调整对应版本,就都可以解决了
3AttributeError: ‘module’ object has no attribute ‘imread’
需要安装pillow.
可以使用如下命令
conda install pillow
或者
pip install pillow
官方scipy中提到,imread is deprecated! imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use imageio.imread instead.
SciPy1.0.0不赞成使用imread,在1.2中已经弃用,可以使用imageio.imread来代替
本文解决TensorFlow与Keras版本不匹配导致的ImportError及AttributeError问题,通过调整TensorFlow版本至2.0.0并适配Keras子模块,确保代码正常运行。同时,提供了解决PIL模块缺失及SciPy中imread弃用的替代方案。

被折叠的 条评论
为什么被折叠?



