Keras: ImportError: No module named data_utils
Keras: ImportError: No module named data_utils
我正在尝试导入模块 keras.utils.data_utils
但它不起作用。但是,我可以找到这个模块here。它确实存在。为什么我不能导入它,而我可以导入一些其他模块,如 keras.models
和 keras.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
编辑:
请参阅 以获得答案。
我看了 https://pypi.python.org/pypi/Keras/0.1.3 and there is no file named data_utils.py in the utils folder. However the github does include this file: https://github.com/fchollet/keras 的 tar.gz。
尽管 answer is correct but is not complete. Thanks to Ben J.'s answer but Tadhg McDonald-Jensen is the first one offering me the answers 。
总结一下
我是用pip install keras
安装keras
的,但是没有按照this安装最新版本的keras
。这就是为什么我可以做 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
的原因。因为它不在以前的版本中。
SO,只要把他们的github、cd
clone
、keras
放进去,运行sudo python setup.py install
就可以解决这个问题.
请记住,如果您已经这样做 pip install keras
,您必须通过多次执行此 pip uninstall keras
直到没有 keras
来确保清除所有已安装的 keras
版本] 存在,然后执行此操作 sudo python setup.py install
。
我希望你的问题现在已经解决,如果没有:
sudo pip install git+git://github.com/fchollet/keras.git --upgrade
应该为您完成这项工作。
这可能会解决您的问题。
sudo -H pip3 install git+https://github.com/fchollet/keras.git --upgrade
我正在尝试导入模块 keras.utils.data_utils
但它不起作用。但是,我可以找到这个模块here。它确实存在。为什么我不能导入它,而我可以导入一些其他模块,如 keras.models
和 keras.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
编辑:
请参阅
我看了 https://pypi.python.org/pypi/Keras/0.1.3 and there is no file named data_utils.py in the utils folder. However the github does include this file: https://github.com/fchollet/keras 的 tar.gz。
尽管
总结一下
我是用pip install keras
安装keras
的,但是没有按照this安装最新版本的keras
。这就是为什么我可以做 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
的原因。因为它不在以前的版本中。
SO,只要把他们的github、cd
clone
、keras
放进去,运行sudo python setup.py install
就可以解决这个问题.
请记住,如果您已经这样做 pip install keras
,您必须通过多次执行此 pip uninstall keras
直到没有 keras
来确保清除所有已安装的 keras
版本] 存在,然后执行此操作 sudo python setup.py install
。
我希望你的问题现在已经解决,如果没有:
sudo pip install git+git://github.com/fchollet/keras.git --upgrade
应该为您完成这项工作。
这可能会解决您的问题。
sudo -H pip3 install git+https://github.com/fchollet/keras.git --upgrade