Python(Canopy)的Theano包返回错误:无法导入名称gof

时间:2015-05-21 07:39:06

标签: python canopy theano scikits

这样,错误将使用from sknn.mlp import *中的Enthought Canopy返回:

ImportError                               Traceback (most recent call last)
C:\Users\User_Account\Desktop\axxx.py in <module>()
----> 1 from sknn.mlp import *

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\sknn\mlp.py in <module>()
     13 
     14 import numpy
---> 15 import theano
     16 import sklearn.base
     17 import sklearn.pipeline

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\__init__.py in <module>()
     53     object2, utils)
     54 
---> 55 from theano.compile import (
     56     SymbolicInput, In,
     57     SymbolicOutput, Out,

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\__init__.py in <module>()
      7         SpecifyShape, specify_shape, register_specify_shape_c_code)
      8 
----> 9 from theano.compile.function_module import *
     10 
     11 from theano.compile.mode import *

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\function_module.py in <module>()
     15 
     16 import theano
---> 17 from theano import gof
     18 from theano.compat import partial
     19 import theano.compile.mode

ImportError: cannot import name gof 

In [3]: %run "C:/Users/Rahimikia/Desktop/axxx.py"
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
C:\Users\User_Account\Desktop\axxx.py in <module>()
----> 1 import theano

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\__init__.py in <module>()
     53     object2, utils)
     54 
---> 55 from theano.compile import (
     56     SymbolicInput, In,
     57     SymbolicOutput, Out,

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\__init__.py in <module>()
      7         SpecifyShape, specify_shape, register_specify_shape_c_code)
      8 
----> 9 from theano.compile.function_module import *
     10 
     11 from theano.compile.mode import *

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\function_module.py in <module>()
     15 
     16 import theano
---> 17 from theano import gof
     18 from theano.compat import partial
     19 import theano.compile.mode

ImportError: cannot import name gof 

In [4]: %run "C:/Users/Rahimikia/Desktop/axxx.py"
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
C:\Users\User_Account\Desktop\axxx.py in <module>()
----> 1 import theano

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\__init__.py in <module>()
     53     object2, utils)
     54 
---> 55 from theano.compile import (
     56     SymbolicInput, In,
     57     SymbolicOutput, Out,

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\__init__.py in <module>()
      7         SpecifyShape, specify_shape, register_specify_shape_c_code)
      8 
----> 9 from theano.compile.function_module import *
     10 
     11 from theano.compile.mode import *

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\function_module.py in <module>()
     15 
     16 import theano
---> 17 from theano import gof
     18 from theano.compat import partial
     19 import theano.compile.mode

ImportError: cannot import name gof 

In [5]: %run "C:/Users/Rahimikia/Desktop/axxx.py"
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
C:\Users\User_Account\Desktop\axxx.py in <module>()
----> 1 import theano

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\__init__.py in <module>()
     53     object2, utils)
     54 
---> 55 from theano.compile import (
     56     SymbolicInput, In,
     57     SymbolicOutput, Out,

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\__init__.py in <module>()
      7         SpecifyShape, specify_shape, register_specify_shape_c_code)
      8 
----> 9 from theano.compile.function_module import *
     10 
     11 from theano.compile.mode import *

C:\Users\User_Account\AppData\Local\Enthought\Canopy\User\lib\site-packages\theano\compile\function_module.py in <module>()
     15 
     16 import theano
---> 17 from theano import gof
     18 from theano.compat import partial
     19 import theano.compile.mode

ImportError: cannot import name gof 

我该如何解决这个问题?我使用包管理器安装了mingwlibpython,并在Windows 8.1中使用Theano安装了pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git开发人员版本。

1 个答案:

答案 0 :(得分:-1)

您可以在此处阅读此错误的历史记录:

https://github.com/Theano/Theano/issues/2406

它说

  

问题似乎是编译试图链接   静态库libpython2.7.a,而不是动态版本   库(应该类似于libpython2.7.so)。

以后

  嘿,谢谢你的回复,我做了重拍python并做了altinstall   ,解决了这个问题。

你应该重建Python,它会没事的。

<强>更新

我认为你应该摆脱Canopy并手动安装Python。 Canopy似乎是Python和一些科学软件包的现成版本,我想Theano现在不会在它上面工作。

谷歌有关如何在Windows上安装python的说明(我从未使用过Windows系统),例如:http://www.anthonydebarros.com/2014/02/16/setting-up-python-in-windows-8-1/

然后通过pip安装所有必需的软件包。