Keras:导入错误:没有名为 data_utils 的模块

新手上路,请多包涵

我正在尝试导入模块 keras.utils.data_utils 但它不起作用。但是,我可以 在这里 找到这个模块。它确实存在。为什么我不能导入它,而我可以导入一些其他模块,如 keras.modelskeras.layers.core

 cliu@cliu-ubuntu:bin$ python
Python 2.7.9 (default, Apr  2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> from keras.models import Sequential
>>> from keras.layers.core import Dense, Activation, Dropout
>>> from keras.layers.recurrent import LSTM
>>> from keras.utils.data_utils import get_file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named data_utils

编辑:

在这里 查看答案。

原文由 fluency03 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2.2k
2 个回答

尽管 这个 答案是正确的,但并不完整。感谢 Ben J. 的回答,但 Tadhg McDonald-Jensen 是第一个在 这里 提供答案的人。

总结一下

我正在使用 pip install keras 安装 keras ,但它没有根据 这个 安装最新版本的 keras 。 That is why I could do things like from keras.models import Sequential , from keras.layers.core import Dense, Activation, Dropout , and from keras.layers.recurrent import LSTM but not from keras.utils.data_utils import get_file .因为它不在以前的版本中。

SO, just clone the keras from their github , cd into it, and run sudo python setup.py install will solve this problem.

请记住,如果您已经这样做了 pip install keras ,您必须确保清除所有 keras 您通过这样做安装的版本 keras e18b2535300cfffbb6700f7eb-1 直到很多时间 pip uninstall keras --- 存在,然后执行此操作 sudo python setup.py install

原文由 fluency03 发布,翻译遵循 CC BY-SA 3.0 许可协议

我查看了来自 https://pypi.python.org/pypi/Keras/0.1.3 的 tar.gz,在 utils 文件夹中没有名为 data_utils.py 的文件。但是 github 确实包含这个文件: https ://github.com/fchollet/keras。

原文由 Ben J. 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题