Keras: ImportError: No module named data_utils

42,668

Solution 1

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.

Solution 2

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.

Share:
42,668
fluency03
Author by

fluency03

Perfection is finally attained not when there is no longer more to add, but when there is no longer anything to take away.

Updated on August 08, 2020

Comments

  • fluency03
    fluency03 over 3 years

    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.

  • Mona Jalal
    Mona Jalal over 7 years
    Could not find any downloads that satisfy the requirement upgrade
  • deepgradient
    deepgradient over 6 years
    yeah, no space after --