[英]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 这是我解决同样问题的方法
conda update conda
conda update conda
conda update --all
conda update --all
conda install mingw libpython
conda install mingw libpython
pip install git+git://github.com/Theano/Theano.git
pip install git+git://github.com/Theano/Theano.git
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创建环境/工作区
C:\\conda create --name neuralnets python=3.5
C:\\activate neuralnets
Install everything (notice the neuralnets workspace in parenthesis on each line). 安装一切 (注意每行上括号中的神经网络工作区)。 Accept any dependencies each of those steps wants to install:
接受每个步骤要安装的任何依赖项:
(neuralnets) C:\\conda install theano
(neuralnets) C:\\conda install mingw libpython
(neuralnets) C:\\pip install tensorflow
(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.
否则可能会出现断言错误。
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
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
After conda commands it's required to accept process - Proceed ([y]/n)? 在conda命令之后,它需要接受进程 - 继续([y] / n)?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.