简体   繁体   English

如何在Windows上的Anaconda Python中安装Keras和Theano?

[英]How do I install Keras and Theano in Anaconda Python on Windows?

I am trying to work on neural networks in Python using the following Keras packages: 我正在尝试使用以下Keras包在Python中使用神经网络:

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 am getting 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 . 安装已安装的conda install keras Later I tried to use pip install Theano , but it did not work. 后来我尝试使用pip install Theano ,但它没有用。 I Tried to install using pip install git , but I am getting this error: cannot find command git. 我尝试使用pip install git ,但是我收到此错误: cannot find command git. So I installed Git and I set the environment variables. 所以我安装了Git并设置了环境变量。

So, is there any procedure to install these packages? 那么,有没有安装这些软件包的程序?

It is my solution for the same problem 这是我解决同样问题的方法

  • Install TDM GCC x64. 安装TDM GCC x64。
  • Install Anaconda x64. 安装Anaconda x64。
  • Open the Anaconda prompt 打开Anaconda提示符
  • Run conda update conda 运行conda update conda
  • Run conda update --all 运行conda update --all
  • Run conda install mingw libpython 运行conda install mingw libpython
  • Install the latest version of Theano, pip install git+git://github.com/Theano/Theano.git 安装最新版本的Theano, pip install git+git://github.com/Theano/Theano.git
  • Run pip install git+git://github.com/fchollet/keras.git 运行pip install git+git://github.com/fchollet/keras.git

The trick is that you need to create an environment/workspace for Python . 诀窍是你需要为Python创建一个环境/工作区 This solution should work for Python 2.7 but at the time of writing keras can run on python 3.5, especially if you have the latest anaconda installed (this took me awhile to figure out so I'll outline the steps I took to install KERAS in python 3.5): 这个解决方案应该适用于Python 2.7但是在编写本文时keras可以在python 3.5上运行,特别是如果你安装了最新的anaconda(这花了我一段时间才弄明白所以我将概述我在python中安装KERAS的步骤) 3.5):

Create environment/workspace for Python 3.5 为Python 3.5创建环境/工作区

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

Install everything (notice the neuralnets workspace in parenthesis on each line). 安装一切 (注意每行上括号中的神经网络工作区)。 Accept any dependencies each of those 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

Test it out: 测试出来:

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

Just remember, if you want to work in the workspace you always have to do: 请记住,如果你想在工作区工作,你总是要做:

C:\activate neuralnets

so you can launch Jupyter for example (assuming you also have Jupyter installed in this environment/workspace) as: 所以你可以启动Jupyter(假设你也在这个环境/工作区中安装了Jupyter):

C:\activate neuralnets
(neuralnets) jupyter notebook

You can read more about managing and creating conda environments/workspaces at the follwing URL: https://conda.io/docs/using/envs.html 您可以在以下URL中阅读有关管理和创建conda环境/工作区的更多信息: https//conda.io/docs/using/envs.html

在带有anaconda的windows中,只需继续使用conda提示符并使用此命令

conda install --channel https://conda.anaconda.org/conda-forge keras

I use macOS and used to have the same problem. 我使用macOS并且曾经有同样的问题。
Running the following command in the terminal saved me: 在终端中运行以下命令保存了我:

conda install -c conda-forge keras tensorflow

Hope it helps. 希望能帮助到你。

In case you want to train CNN's with the theano backend like the Keras mnist_cnn.py example: 如果您想像在Keras mnist_cnn.py示例中那样使用theano后端训练CNN:

You better use theano bleeding edge version. 你最好使用theano流血边版。 Otherwise there may occur assertion errors. 否则可能会出现断言错误。

  • Run Theano bleeding edge 跑Theano流血的边缘
    pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
  • Run Keras (like 1.0.8 works fine) 运行Keras(像1.0.8一样正常)
    pip install git+git://github.com/fchollet/keras.git

install by this command given below conda install -c conda-forge keras 通过以下给出的命令安装conda install -c conda-forge keras

this is error "CondaError: Cannot link a source that does not exist" ive get in win 10. for your error put this command in your command line. 这是错误“CondaError:无法链接不存在的源”我已经获胜10.因为您的错误将此命令放在命令行中。

conda update conda conda更新conda

this work for me . 这项工作对我来说。

In windows environment with Anconda. 在使用Anconda的Windows环境中。 Go to anconda prompt from start. 从头开始转到anconda提示符。 Then if you are behind proxy then .copndarc file needs to eb updated with the proxy details. 然后,如果你落后于代理,那么.copndarc文件需要使用代理详细信息进行更新。

ssl_verify: false channels: - defaults proxy_servers: http: http://xx.xx.xx.xx:xxxx https: https://xx.xx.xx.xx:xxxx ssl_verify:false channels: - 默认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 was getting ssl error. 我有ssl_verify最初标记为'True'然后我得到ssl错误。 So i turned it to false as above and then ran the below commands 所以我把它变成了如上所述的假,然后运行以下命令

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

My python version is 3.6.7 我的python版本是3.6.7

Anaconda with Windows Anaconda与Windows

  • Run anaconda prompt with administrator privilages 使用管理员权限运行anaconda提示符
  • conda update conda conda更新conda
  • conda update --all conda update --all
  • conda install mingw libpython conda安装mingw libpython
  • conda install theano conda安装theano

After conda commands it's required to accept process - Proceed ([y]/n)? 在conda命令之后,它需要接受进程 - 继续([y] / n)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Windows 上的 Anaconda Python 2.7 x64 上安装 Theano? - How to install Theano on Anaconda Python 2.7 x64 on Windows? 如何在Anaconda Python 2.7 Windows中安装CGAL - How to install CGAL in anaconda python 2.7 windows 如何在Windows 7 64位计算机上为蟒蛇的python 3.5安装cvxopt? - how to install cvxopt on windows 7 64 bit machine for python 3.5 of anaconda? 如何在Ubuntu 16.04上将theano添加到anaconda python v2.7? - How to add theano to anaconda python v2.7 on ubuntu 16.04? 带有 Anaconda Python 的 PyQt Windows 安装程序——未找到 PyQt4; 我该如何排除故障? - PyQt Windows installer with Anaconda Python--PyQt4 not found; how do I troubleshoot? 如何在Windows上为Python 2.7 Pillow安装zlib? - How do I install zlib for Python 2.7 Pillow on Windows? 如何在 64 位 Windows 7 上安装 python_ldap? - How do I install python_ldap on 64 bit windows 7? 如何在arm64,Ubuntu 16.04上安装Keras? - How do I install Keras on arm64, Ubuntu 16.04? 如何在Windows 10上安装snappy C库,以便与Anaconda中的python-snappy一起使用? - How to install snappy C libraries on Windows 10 for use with python-snappy in Anaconda? 如何在Windows 8.1(win64)中安装Pytesseract(visual studio 2012 + python + anaconda) - How To Install Pytesseract in windows 8.1(win64) (visual studio 2012+python+anaconda)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM