导入theano时出错"无法导入名称gof"

Huy*_* Vu 9 python-2.7 theano

我目前得到错误

ImportError:无法导入名称gof

当导入theano时.

>>> import theano

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import theano
  File "C:\Python27\lib\site-packages\theano\__init__.py", line 63, in <module>
    from theano.compile import (
  File "C:\Python27\lib\site-packages\theano\compile\__init__.py", line 9, in <module>
    from theano.compile.function_module import *
  File "C:\Python27\lib\site-packages\theano\compile\function_module.py", line 16, in <module>
    from theano import gof
ImportError: cannot import name gof
Run Code Online (Sandbox Code Playgroud)

我正在使用python 2.7.10().Theano安装使用pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git.希望能得到你解决这个问题的建议

nou*_*uiz 5

大多数情况下,当我看到这个错误时,它是由这两个错误引起的:

1)Theano中的语法错误.更新Theano并确保没有本地修改.我在Theano的主人看到了这个错误,但以防万一.

2)当安装了多个版本的Theano时.

在这两种情况下,删除所有版本的Theano.做多次,以确保没有剩余.然后重新安装.

从内存中,这总是解决了在开发过程中不是语法错误的问题(但不是在你使用的Theano主版本中)


Tim*_*ara 5

ImportError可能是因为 Theano无法编译gof模块本身造成的。如果是这种情况,您将看到一条类似“ Exception: Compilation Failed (return status=1): C:\Long\Path\...\mod.cpp:1: sorry, unimplemented: 64-bit mode not compiled in”的错误消息。

使用 Conda 修复

如果您要安装theano到某个conda环境中,请确保您有可用于该环境的 C 编译器。

命令

conda install m2w64-toolchain
Run Code Online (Sandbox Code Playgroud)

将为您的环境提供一个与计算机其余部分隔离的 C 编译器。

m2w64-toolchain软件包安装后,import theano应该可以工作

手动修复

如果您自己安装 Theano,这些 线程中的两点可能会有所帮助: