I’m trying to run the following example from keras
but I get this error:
ImportError
Traceback (most recent call last)
<ipython-input-58-50de27eea0f8> in <module>()
8 import numpy as np
9 import matplotlib.pyplot as plt
---> 10 from keras.models import Sequential
11 from keras.layers import Dense, LSTM
12
/usr/local/lib/python2.7/dist-packages/keras/__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
/usr/local/lib/python2.7/dist-packages/keras/utils/__init__.py in <module>()
1 from __future__ import absolute_import
----> 2 from . import np_utils
3 from . import generic_utils
4 from . import data_utils
5 from . import io_utils
ImportError: cannot import name np_utils
I’m using Ubuntu and I installed keras with:
sudo pip install keras
This question was already asked but there was no answer:
Keras: Cannot Import Name np_utils
Rohit Patel
np_utils
is a separate package (and a keras dependency – which doesn’t get install with it). Can be installed using pip:using – Keras==2.0.6
Suggestion:
For some odd (and still unknown) reasons, even after installing the import
didn’t work – I had to restart the notebook (first restart even didn’t work), and once it worked, I got stuck again for same import call (gave exception for
no module named tensorflow
) – as in utils there’s another importfrom . import conv_utils
, which required the tensorflow.I did try installing tensorflow using pip install tensorflow gave:
even this gist didn’t work for me.
Finally, I installed Anaconda – which have all the scientific packages (numpy, scipy, scikit-learn,..) pre-installed. Installed keras:
Best thing was, it even installed tensorflow as its dependency.