Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras: ImportError: No module named data_utils

I am trying to import the module keras.utils.data_utils but its not working. However, I can find this module here. It is indeed existing. Why I cannot import it while I can import some other modules likekeras.models and 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

Edit:

See here for the answer.

like image 848
fluency03 Avatar asked Mar 10 '16 00:03

fluency03


2 Answers

Even though this 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 here.

Summarize it

I was using pip install keras to install keras, but it did not install the latest version of keras according to this. 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. Because it is not in the previous versions.

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

REMEMBER, if you already did this pip install keras, you have to make sure clear all keras versions you have installed by doing this pip uninstall keras many time until no keras existing, then do this sudo python setup.py install.

like image 155
fluency03 Avatar answered Oct 22 '22 05:10

fluency03


I looked at the tar.gz from 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.

like image 29
Ben J. Avatar answered Oct 22 '22 04:10

Ben J.