No module named 'keras.preprocessing'; 'keras' is not a package

807 views
Skip to first unread message

priyankas...@gmail.com

unread,
Oct 22, 2019, 3:29:02 AM10/22/19
to Keras-users
from keras.preprocessing.text import one_hot
from keras.preprocessing.sequence import pad_sequences
from keras.models import Sequential
from keras.layers.core import Activation, Dropout, Dense
from keras.layers import Flatten, LSTM
from keras.layers import GlobalMaxPooling1D
from keras.models import Model
from keras.layers.embeddings import Embedding
from keras.preprocessing.text import Tokenizer
from keras.layers import Input



error

 from keras.preprocessing.text import one_hot

ModuleNotFoundError: No module named 'keras.preprocessing'; 'keras' is not a package

Matias Valdenegro

unread,
Oct 22, 2019, 4:35:28 AM10/22/19
to keras...@googlegroups.com

Did you by chance name your script as keras.py ?

 

On Tuesday, 22 October 2019 09:29:02 CEST priyankas...@gmail.com wrote:

> from keras.preprocessing.text import one_hot

> from keras.preprocessing.sequence import pad_sequences

> from keras.models import Sequential

> from keras.layers.core import Activation, Dropout, Dense

> from keras.layers import Flatten, LSTM

> from keras.layers import GlobalMaxPooling1D

> from keras.models import Model

> from keras.layers.embeddings import Embedding

> from keras.preprocessing.text import Tokenizer

> from keras.layers import Input

>

>

>

> *error*

Umberto Michelucci

unread,
Oct 23, 2019, 8:11:22 AM10/23/19
to Keras-users
Try to import keras from tf

from tensorflow.keras.preprocessing.text import one_hot

Umberto

Lance Norskog

unread,
Oct 23, 2019, 1:30:15 PM10/23/19
to Umberto Michelucci, Keras-users
I have found it worthwhile to start with tutorials and then change whatever I need to, rather than code from scratch.
In general, Keras is not a "closed" abstraction. It is "leaky". There are a lot of internal aspects that you have to understand to get anything done.

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/29b5103d-6eae-42cf-b95c-1b40c8cd03cb%40googlegroups.com.


--
Lance Norskog
lance....@gmail.com
Redwood City, CA

geek_kid

unread,
Oct 24, 2019, 4:47:47 AM10/24/19
to Keras-users
Sorry to ask the obvious question but have you installed keras?
Reply all
Reply to author
Forward
0 new messages