问题描述
环境:win10+anaconda+tf 1.2.0+keras 2.0.6+py 3.6.2
import tensorflow.keras as keras
在使用tensorflow.keras遇到报错说No module named keras
在看了几个博客后,我发现情况并不一样,具体地说,我甚至不能成功地执行以下语句
[En]
After referring to several blogs, I found that the situation was not the same, specifically, I could not even successfully implement the following statements
import tensorflow as tf
from tensorflow import keras
print(tf.VERSION)
print(keras.__version__)
print(tf.__path__)
print(keras.__path__)
此段代码运行结果为报错:cannot import keras
问题解决
经参考下列博客https://blog.csdn.net/gyx1549624673/article/details/104317816
意识到可能是tf的版本问题,遂升级tf及keras版本至最新
pip install –upgrade tensorflow
pip install –upgrade keras
注:tf为CPU版本
但问题是忽略了自己的python编译器版本(离谱),导致报错
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: 找不到指定的模块。
最终解决
pip install tensorflow ==1.12.0
pip install keras ==2.2.4Original: https://blog.csdn.net/m0_47088143/article/details/120676887
Author: 西敏寺的夜空-
Title: import tensorflow.keras as keras 报错No Module named keras
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/511616/
转载文章受原作者版权保护。转载请注明原作者出处!