Rafael_Espericueta
Rafael_Espericueta

Reputation: 515

Jupyter notebook - "No module named keras", but it was imported

I'm running Jupyter notebook in a conda virtual environment (Ubuntu), and first entered:

import tensorflow as tf
from tensorflow import keras
from keras.wrappers.scikit_learn import KerasClassifier

As you can see in the image below, it appears that keras has been imported. However, when I try to import a function from keras.wrappers.scikit_learn I get an error message suggesting that keras hasn't been imported. What am I missing here??

enter image description here

Upvotes: 1

Views: 4567

Answers (2)

faisal
faisal

Reputation: 353

Make sure you have keras installed as separate package as well.

pip install keras

Upvotes: 2

Rafael_Espericueta
Rafael_Espericueta

Reputation: 515

I'm not sure why (and am open to answers!), but the following syntax results in no errors:

from tensorflow.keras.wrappers.scikit_learn import KerasClassifier

Upvotes: 4

Related Questions