如何修复“ModuleNotFoundError:没有名为“tensorflow.python.keras”的模块导入 ImagePrediction?

Bla*_*lvo 3 python keras tensorflow

我想运行张量流进行图像识别。我已经按照它的所有步骤进行操作,并且 keras 和 tensorflow 都安装在我的计算机上。这篇文章中的步骤: https: //github.com/OlafenwaMoses/ImageAI/ 但是当我尝试时: from imageai.Prediction import ImagePrediction

我不断收到错误: fromtensorflow.python.keras.preprocessing import image ModuleNotFoundError:没有名为“tensorflow.python.keras”的模块

我认为该错误来自我安装的“tensorflow”。当我尝试以下方法时: pip3 install --upgrade tensorflow 我收到错误: Could not find a version that satisfies the required tensorflow (from versions: ) Nomatching distribution found for tensorflow

所以我改用: python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

我从这篇文章中得到它:使用 pip 找不到 TensorFlow

我的猜测是,第一个错误促使我出现第二个错误,但我不知道如何修复其中任何一个。

有什么建议么?

我的代码直到问题是:

导入张量流

从 imageai.Prediction 导入 ImagePrediction

小智 5

尝试写作

from keras.preprocessing import image
Run Code Online (Sandbox Code Playgroud)

代替

from tensorflow.python.keras.preprocessing import image
Run Code Online (Sandbox Code Playgroud)

对所有 Keras 调用执行相同的操作。