Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
928 views
in Technique[技术] by (71.8m points)

python - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...