1

I have installed keras followed by tensorflow.

from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense

When I execute keras sequential model, I get an error message stating that

Import Error Trackback (most recent call last)
ImportError: cannot import name 'Sequential' from 'keras.models' (C:\Users\murthy.p\AppData\Local\Continuum\anaconda4\lib\site-packages\keras\models__init__.py)

0

2 Answers 2

7

Firstly, if you're importing more than one thing from say keras.models or keras.layers put them on one line.

For this specific problem, try importing it from tensorflow which is essentially the keras API. I'm quite confident it should work!

from tensorflow.keras import Sequential

To install tensorflow: pip install tensorflow==2.0.0

1
  • 2
    4 hours of installation issues and this "pip install" command is fixed the issue within minutes (inside the Anaconda console). Amen to this solution!
    – Mugen
    Apr 22, 2021 at 8:43
1

I think you didn't install keras properly you can install it in the command line of the environment you are using by applying the following code

pip install keras 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.