Reputation: 1135
I was running Jupyter Notebook and the following error occurs
ModuleNotFoundError
Traceback (most recent call last) in ---->from keras.models import Sequential
from keras.layers import (
Conv2D, MaxPooling2D, Flatten, Dense, Dropout)ModuleNotFoundError: No module named 'keras'
I have tried using
import sys; sys.path
and found this
['/home/xxx/notebook',
'/home/xxx/anaconda3/lib/python37.zip',
'/home/xxx/anaconda3/lib/python3.7',
'/home/xxx/anaconda3/lib/python3.7/lib-dynload',
'',
'/home/xxx/anaconda3/lib/python3.7/site-packages',
'/home/xxx/anaconda3/lib/python3.7/site-packages/IPython/extensions',
'/home/xxx/.ipython']
Is there any problem with the installation? Do I need to reinstall everything from python to anaconda. Would some be able to point me to a proper installation of anaconda
BTW, if u have installed python, should you install python package through anaconda again
Thanks
Upvotes: 10
Views: 58027
Reputation: 1
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense,Dropout,Activation, Flatten, Conv2D, MaxPooling2D
These two import statements worked for me.
Upvotes: 0
Reputation: 21
Create a virtual environment and install all packages and specially jupyter-notebook in it. Some times it is necessary to install jupyter-notebook in each virtual environment to work properly with other libraries. It is preferred to use anaconda.
After creating your virtual env use this command to install jupyter:
conda install -c anaconda jupyter
Upvotes: 2
Reputation: 39
Install packages in Anaconda Navigator -> Enviroments -> Play button -> Open Terminal -> conda install keras
Upvotes: 0
Reputation: 98
If you have installed all the required packages in a virtual/conda environment, have you tried saving the environment as an ipython kernel? I got those errors when I tried to launch a jupyter notebook from my virtual environment but I hadn't explicitly created a kernel for it.
https://ipython.readthedocs.io/en/stable/install/kernel_install.html
Upvotes: 0
Reputation: 1547
You have to install all the dependencies first before using it. Try using
by installing it with conda command it manage your versions compatibility with other libraries.
with pip install libraries will only install in your current environment and the latest version of the library sometimes latest libraries are not compatible with the other libraries so we have to take care of version compatibility.
Upvotes: 14
Reputation: 459
keras is actually part of tensorflow so all you have to do is just
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense,Dropout,Activation, Flatten, Conv2D, MaxPooling2D
cheers mate
Upvotes: 11