Cannot run keras
Asked Answered
J

2

1

I want to run keras on anaconda for convolution neural network using mnist handwriting recognition. A day before everything worked fine but as I try to run the same program, i get the following error in the first line:

from keras.datasets import mnist (first line of code)

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

I also created virtual environment to use python 3.5 as my python version is 3.6. I have installed both keras and tensorflow. How do i fix the above error? Perhaps it is related to path and not error with keras. My anaconda is installed in E: whearas working environment is C:\Users\Prashant Mahato.

Jennelljenner answered 8/6, 2017 at 20:4 Comment(3)
can you activate your environment in cmd? (Type: activate environmentname)Pga
yes i activated it as wellJennelljenner
then your environment is working. If you run python in your active environment via cmd can you import keras? If not, go to your environment folder and check if keras is in your Lib/site-packages folderPga
B
0

Do you get an error message if you just import keras? I was getting a similar error in the command line and then implemented in Spyder (using Anaconda) and it worked fine.

Binny answered 19/7, 2017 at 15:58 Comment(0)
M
0

Here is how I install Keras and other related dependencies

conda create -n <Environment_Name> python=3.6
activate <Environment_Name>
conda update --all 
conda install  mingw libpython
conda install  scipy
conda install  numpy
conda install  mkl
conda install  -c conda-forge tensorflow
conda install  theano
pip install  pyyaml
pip install  h5py
pip install  keras
conda install -c conda-forge  tmux
conda install  pandas
condas install  pillow
conda  install  scikit-learn
conda install  -c menpo opencv3

To check if everything is work as it should just import all the packages in python within the environment created.

I'm running Windows 10 and Anaconda 4.2

If running Ubuntu, replace

activate <Environment_Name>

with

source activate <Environment_Name>

HTH.

Misapprehend answered 14/9, 2017 at 10:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.