ImportError:No module named keras.layers.core

16,859 views
Skip to first unread message

xfsc...@gmail.com

unread,
Jun 15, 2016, 9:59:38 AM6/15/16
to Keras-users

Hi all,

I installed tensorflow and keras. But when I run the example file I got below error.
Should there be any wrong when I install keras?


(tensorflow2)scott@ubuntu:~/Keras_LSTM$ python recurrent_keras_power.py
Traceback (most recent call last):
  File "recurrent_keras_power.py", line 5, in <module>
    from keras.layers.core import Dense, Activation, Dropout
ImportError: No module named keras.layers.core
(tensorflow2)scott@ubuntu:~/Keras_LSTM$




Thanks,
Scott

Daπid

unread,
Jun 15, 2016, 11:05:34 AM6/15/16
to xfsc...@gmail.com, Keras-users
On 15 June 2016 at 15:59, <xfsc...@gmail.com> wrote:
> (tensorflow2)scott@ubuntu:~/Keras_LSTM$ python recurrent_keras_power.py
> Traceback (most recent call last):
> File "recurrent_keras_power.py", line 5, in <module>
> from keras.layers.core import Dense, Activation, Dropout
> ImportError: No module named keras.layers.core
> (tensorflow2)scott@ubuntu:~/Keras_LSTM$

That sounds like you are missing keras. Try:

python -c "import keras; print(keras.__version__)"

xfsc...@gmail.com

unread,
Jun 15, 2016, 8:26:39 PM6/15/16
to Keras-users, xfsc...@gmail.com
Thanks, I tried but got same error as below.


(tensorflow)scott@ubuntu:~/Keras_LSTM$ conda list
# packages in environment at /home/scott/anaconda3/envs/tensorflow:
#
keras                     1.0.4                     <pip>
numpy                     1.11.0                    <pip>
openssl                   1.0.2h                        1
pip                       8.1.2                    py27_0
protobuf                  3.0.0b2                   <pip>
python                    2.7.11                        0
pyyaml                    3.11                      <pip>
readline                  6.2                           2
setuptools                23.0.0                   py27_0
six                       1.10.0                    <pip>
sqlite                    3.13.0                        0
tensorflow                0.8.0                     <pip>
theano                    0.8.2                     <pip>
tk                        8.5.18                        0
wheel                     0.29.0                   py27_0
zlib                      1.2.8                         3
(tensorflow)scott@ubuntu:~/Keras_LSTM$ python recurrent_keras_power.py
Traceback (most recent call last):
  File "recurrent_keras_power.py", line 5, in <module>
    from keras.layers.core import Dense, Activation, Dropout
ImportError: No module named keras.layers.core
(tensorflow)scott@ubuntu:~/Keras_LSTM$ python -c "import keras; print(keras.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named keras
(tensorflow)scott@ubuntu:~/Keras_LSTM$




在 2016年6月15日星期三 UTC+8下午11:05:34,David Menéndez Hurtado写道:

Daπid

unread,
Jun 16, 2016, 3:07:05 AM6/16/16
to xfsc...@gmail.com, Keras-users
On 16 June 2016 at 02:26, <xfsc...@gmail.com> wrote:
>
> (tensorflow)scott@ubuntu:~/Keras_LSTM$ conda list
> # packages in environment at /home/scott/anaconda3/envs/tensorflow:
> #
> keras 1.0.4 <pip>

So it looks like the python where you have installed keras and the one
you are running are different. You should adjust your PATH so that it
contains your conda binaries.

To make sure:

$ which conda
$ which python

should point to two files in the same directory.

hrith...@gmail.com

unread,
Sep 15, 2017, 11:01:07 AM9/15/17
to Keras-users
i didnot understand what u r saying

Peter Chen

unread,
May 13, 2021, 5:06:46 PM5/13/21
to Keras-users
from tensorflow.keras.layers import Activation, Dense
# tensorflow 2.4.0, the Dense move from keras.layers.core move to tensroflow.keras.layers
# from keras.layers.core import Dense
# It works for me.
Reply all
Reply to author
Forward
0 new messages