3

I created a new conda env with

conda create --name tf tensorflow=2.6

and tried to compile

import tensorflow as tf
model = tf.keras.models.Sequential()

resulting in ModuleNotFoundError: No module named 'keras'

conda install keras

doesn't change anything. I could go with

from tensorflow.keras.models import Sequential
model = Sequential()

but when I pip install tensorflow-addons and

from tensorflow_addons.seq2seq.sampler import TrainingSampler

I end up with the same error

uninstalling tensorflow, installing just keras and trying

from keras.models import Sequential
model = Sequential()

results in the same error

my versions are

tensorflow = 2.6
keras = 2.6
tensorflow-adons = 0.14
5
  • try from tensorflow.keras .models import Sequential Oct 27, 2021 at 6:29
  • @AvishkaDambawinna I tried but I need to use tensorflow_addons. Read the full question
    – SzymonO
    Oct 27, 2021 at 6:37
  • Please checkout these threads . stackoverflow.com/questions/45271344/… edureka.co/community/67388/… Nov 18, 2021 at 4:47
  • I faced the same problem. I had to downgrade tensorflow to 2.5 then it worked. The only command I used is conda create --name tf tensorflow=2.5, no need to install anything else.
    – Gqqnbig
    Dec 18, 2021 at 17:27
  • @Gqqnbig turns out that I had 2 keras versions installed, one from tensorflow and one from tensorflow nightly. Would be wise to check your conda list and pip list for duplicate keras installations
    – SzymonO
    Dec 19, 2021 at 18:08

1 Answer 1

0

What turned out is that I had both keras and keras nightly installed, the problem got resolved after uninstalling keras-nightly. If anyone encounters this check your conda list and pip list for duplicate keras installations

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.