导入theano给出AttributeError:模块'theano'没有属性'gof' [英] Import theano gives the AttributeError: module 'theano' has no attribute 'gof'

查看:219
本文介绍了导入theano给出AttributeError:模块'theano'没有属性'gof'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有python 3. 我使用

I have python 3. I installed "Theano" bleeding edge and "Keras" using

pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git

还有

pip install --upgrade git+git://github.com/Theano/Theano.git

pip install git+git://github.com/fchollet/keras.git

但是当我尝试导入Theano时,出现以下错误:

But when I try to import Theano, I receive the following error:

AttributeError: module 'theano' has no attribute 'gof'

我在网上寻找解决方案,却一无所获...

I looked for a solution online and reached nothing...

这是我收到错误的代码(最后一行产生错误):

This is the piece of code I receive an error on (the last line produces error):

import sys
import numpy as np
import pandas as pd
from sklearn import preprocessing

from keras.models import Sequential

由于我对python没有足够的经验,我完全迷失了方向,无法弄清楚该怎么做...

Since I don't have enough experience with python I'm completely lost and can't figure out what to do...

任何帮助将不胜感激.

推荐答案

问题来自theano的安装错误,与keras本身无关.

The problem arises from a broken installation of theano and has nothing to do with keras itself.

此错误似乎是由于theano安装版本中的冲突所致,如此答案相关问题.

This error seems to be due to conflicts in the installed version of theano, as also suggested in this answer to a related question.

一种简单的方法可以解决此问题,而无需摆弄已安装的版本以及仅将conda用作程序包管理器并让其完成繁琐的工作. 如果选择执行此操作,请注意,应该使用它来管理所有python模块(即使使用最新版本,也可以使用anaconda随附的pip安装软件包).

An easy way that should solve the problem without having to fiddle with the installed version and all that is to use conda as package manager and let it do the dirty work. If you choose to do this be aware that you should manage all of your python modules with it (even though with the latest versions you can install packages with the pip shipped with anaconda itself).

有关如何安装Anaconda的信息,请参见官方文档. 一旦设置了anaconda,您就可以简单地使用conda install theano来安装theano.

See the official documentation for how to install Anaconda. Once anaconda is set up you can install theano using simply conda install theano.

使用conda常常也很方便在与其他python安装隔离的环境中安装某些特定应用程序(例如您的情况下的Keras)所需的软件包,以便于维护. 阅读相关文档,以了解其工作原理.

With conda is also often convenient to install the packages needed for some particular application, like Keras in your case, in an environment isolated from the rest of your python installation, for easier maintenance. Read the relevant docs to see how this would work.

这篇关于导入theano给出AttributeError:模块'theano'没有属性'gof'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆