How to install Keras and Theano in Anaconda Python on Windows?

I am trying to work with neural networks in Python using the following Keras packages:

from keras.utils import np_utils from keras.layers.core import Dense, Activation, Dropout from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation, Flatten from keras.layers.convolutional import Convolution2D, MaxPooling2D from keras.optimizers import SGD 

But I get the following error:

  15 import theano ---> 16 from theano import gof 17 from theano.compat.python2x import partial 18 import theano.compile.mode ImportError: cannot import name gof 

Installing installed conda install keras . Later I tried using pip install Theano , but that did not work. I tried installing using pip install git , but I get this error: cannot find command git. So, I installed Git and I set the environment variables.

So, is there any procedure for installing these packages?

+62
theano keras anaconda
Dec 04 '15 at 21:44
source share
8 answers

This is my solution for the same problem.

  • Install TDM GCC x64.
  • Install Anaconda x64.
  • Open Anaconda invitation
  • Run conda update conda
  • Run conda update --all
  • Run conda install mingw libpython
  • Install the latest version of Theano, pip install git+git://github.com/Theano/Theano.git
  • Run pip install git+git://github.com/fchollet/keras.git
+122
Jan 24 '16 at 12:41
source share

The trick is that you need to create an environment / workspace for Python . This solution should work for Python 2.7, but at the time of writing Keras may work on Python 3.5, especially if you have the latest version of anaconda installed (it took me a while to figure it out, so I will describe the steps that I took to install KERAS in python 3 ,5):

Create Environment / Workspace for Python 3.5

  1. C:\conda create --name neuralnets python=3.5
  2. C:\activate neuralnets

Set everything (pay attention to the working area of ​​neural networks in brackets on each line). Accept any dependencies that each of these steps wants to install:

  1. (neuralnets) C:\conda install theano
  2. (neuralnets) C:\conda install mingw libpython
  3. (neuralnets) C:\pip install tensorflow
  4. (neuralnets) C:\pip install keras

Check this:

 (neuralnets) C:\python -c "from keras import backend; print(backend._BACKEND)" 



Just remember that if you want to work in the workspace, you always need to do:

 C:\activate neuralnets 

so that you can run Jupyter, for example (assuming you also have Jupyter installed in this environment / workspace) like:

 C:\activate neuralnets (neuralnets) jupyter notebook 

You can learn more about managing and creating conda environments / workbenches at the following URL: https://conda.io/docs/using/envs.html

+35
Feb 11 '17 at 4:45
source share

On windows with anaconda just run the conda prompt and use this command

 conda install --channel https://conda.anaconda.org/conda-forge keras 
+27
Dec 12 '16 at 11:01
source share

I am using macOS and had the same problem.
Running the following command in the terminal saved me:

 conda install -c conda-forge keras tensorflow 

Hope this helps.

+13
Aug 17 '17 at 8:47 on
source share

If you want to train CNN with theano backend, for example, Keras mnist_cnn.py example:

Better use the version of theano bleeding edge. Otherwise, approval errors may occur.

  • Theano bleeding edge launch
    pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
  • Launch Keras (e.g. 1.0.8 works fine)
    pip install git+git://github.com/fchollet/keras.git
+3
Sep 11 '16 at 10:54 on
source share

install using the conda install -c conda-forge keras command below

this is the error "CondaError: Unable to bind a source that does not exist", I got in win 10. for your error, put this command on the command line.

Konda update Konda

this work is for me.

0
Sep 06 '18 at 9:52
source share

In a Windows environment with Anconda. Go to the Anconda tooltip from the beginning. Then, if you are behind a proxy server, then the .copndarc file should be updated with the proxy information.

ssl_verify: false channels: - default proxy_servers: http: http: //xx.xx.xx.xx: xxxx https: https: //xx.xx.xx.xx: xxxx

I had ssl_verify, initially marked as "True", then I got an ssl error. So I turned it to false as above and then ran the following commands

Conda update Conda update --all Conda install --channel https://conda.anaconda.org/conda-forge keras Conda update --channel https://conda.anaconda.org/conda-forge tenorflow

My Python Version 3.6.7

0
Mar 25 '19 at 8:46
source share

Anaconda with Windows

  • Run Anaconda with administrator privileges.
  • Konda update Konda
  • Konda update --all
  • Conda install Mingw libpython
  • Konda install Theano

After conda commands you need to accept the process - Continue ([y] / n)?

0
Apr 19 '19 at 9:13
source share



All Articles