Keras: No module named keras

Created on 1 Jan 2017  路  18Comments  路  Source: keras-team/keras

I have installed Anacondapackage on a server as a user account, then I use conda install keras to install kerason it, but then when I run import keras, it raised no module named keras, anyone can help? thanks very much!

stale

Most helpful comment

I had the a similar problem. Following steps helped

1- Open Anaconda Prompt with admin privileges (in windows: right click -> open as admin, etc)
2- Type the command to install you package, e.g.:
conda install -c conda-forge keras tensorflow
If not sure about package name, search web for it.

3- Test if the package was installed correctly. E.g. launch Spider from Anaconda and use command
import keras

4- Restart Rstudio (Session -> Restart R) before trying
library(keras)

PS: now you have to deal with TF's internal errors and warnings like
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
But, that's a whole different story.

All 18 comments

Did your command (: conda install keras) succeed?

keras cannot be installed by conda install keras because package not found.
(my anaconda is anaconda3-4.1.1)

I recommend use pip install keras to install keras.

I had the same issue when i installed keras using conda

I removed it and then installed using sudo pip3 install keras and it worked.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

sudo pip3 install keras fixed it, thanks!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

I had the a similar problem. Following steps helped

1- Open Anaconda Prompt with admin privileges (in windows: right click -> open as admin, etc)
2- Type the command to install you package, e.g.:
conda install -c conda-forge keras tensorflow
If not sure about package name, search web for it.

3- Test if the package was installed correctly. E.g. launch Spider from Anaconda and use command
import keras

4- Restart Rstudio (Session -> Restart R) before trying
library(keras)

PS: now you have to deal with TF's internal errors and warnings like
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
But, that's a whole different story.

If you are using Anaconda 3.6 version, you can type the below command in Anaconda prompt to install keras

conda install -c conda-forge keras

Followed by try importing Dense and sequential libraries from the keras package

from keras.layers import Dense
from keras.models import Sequential

Hope it works

Thanks

I had the a similar problem. Following steps helped

1- Open Anaconda Prompt with admin privileges (in windows: right click -> open as admin, etc)
2- Type the command to install you package, e.g.:
conda install -c conda-forge keras tensorflow
If not sure about package name, search web for it.

3- Test if the package was installed correctly. E.g. launch Spider from Anaconda and use command
import keras

4- Restart Rstudio (Session -> Restart R) before trying
library(keras)

PS: now you have to deal with TF's internal errors and warnings like
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
But, that's a whole different story.

Thanks a lot mate for the detailed steps :)

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import keras

ModuleNotFoundError: No module named 'keras'
this is the issue after installing through conda

I had the same problem and it turned out that conda was not adding the environment site-packages onto the python path.

e.g.
import sys print (sys.path)

did not have C:\ProgramDataAnaconda3\envsfoo\Lib\site-packages present.

I set environment variable PYTHONPATH to C:\ProgramDataAnaconda3\envsfoo\Lib\site-packages and now python can find the packages present within virtual environment.

I restart my conda environment by conda deactivate and then conda activate tf13 and it solved.before this I reinstall my keras by uninstall anything with keras in my tf13 environment.

what to do in jupyter , no module not found

run this command in anaconda prompt
conda install -c conda-forge keras tensorflow

"pip3 install keras"
worked for me

Thanks all, I realized I was in the wrong environment.

pip install keras worked for me!

Hello,

please know that Keras examples worked for me some weeks ago...

I installed Python 3.7 (with env. path), configured with tensorflow and keras:

Name: Keras
Version: 2.4.3
Summary: Deep Learning for humans
Home-page: https://github.com/keras-team/keras
Author: Francois Chollet
Author-email: francois.[email protected]
License: MIT
Location: c:\users\shopp\appdata\local\programs\python\python37\lib\site-packages
Requires: numpy, scipy, h5py, pyyaml
Required-by:

I installed Keras.NET v3.7.4.2 together with its dependencies.

Today running the image example I got this error:

Python.Runtime.PythonException: "ModuleNotFoundError : No module named 'keras'"

Do you have any what the problem could be after (as I said) it worked some weeks ago?

Thanks.

P.S.: Even after deinstalling Cuda dev. kit, Python and related folders and re-installing Python with Keras and TF I now (!) get this error. This is nothing but crazy!

I'm able to import the keras after conda install -c conda-forge keras tensorflow but I couldn't import the layers, while importing I'm encountering the following error

No module named 'keras.layers.img_paths_to_labelsconvolutional'

Was this page helpful?
0 / 5 - 0 ratings