我目前得到错误
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
我正在使用python 2.7.10() . Theano使用 pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
安装 . 希望能得到你解决这个问题的建议
3 回答
大多数情况下,当我看到这个错误时,它是由这两个错误引起的:
1)Theano中的语法错误 . 更新Theano并确保没有本地修改 . 我在Theano的主人看到了这个错误,但以防万一 .
2)当安装了多个版本的Theano时 .
在这两种情况下,删除所有版本的Theano . 做多次,以确保没有剩余 . 然后重新安装 .
从内存中,这总是解决了在开发过程中不是语法错误的问题(但不是在你使用的Theano主版本中)
这个
ImportError
可能是因为Theano是unable to compile the gof module itself . 如果是这种情况,您将看到一条看起来像“Exception: Compilation Failed (return status=1): C:\Long\Path\...\mod.cpp:1: sorry, unimplemented: 64-bit mode not compiled in
”的错误消息 .使用Conda修复
如果要将
theano
安装到conda
环境中,请确保该环境可以使用C编译器 .命令
将为您的环境提供一个C编译器,它与机器的其余部分隔离 .
安装
m2w64-toolchain
软件包后,import theano
应该可以正常工作手动修复
如果您自己安装Theano,these threads中的两点可能会有所帮助:
安装bleeding edge version of Theano
从http://www.lfd.uci.edu/%7Egohlke/pythonlibs/安装
libpython
我假设您使用的是Windows 7或更高版本 .
如果您已安装Python Anaconda,则在打开
pip install theano
之前打开Windows Powershell或命令提示符并键入conda install mingw libpython
现在运行Python和
import theano
Possible errors:
如果你得到RuntimeError:“To use MKL 2018 with Theano you MUST set "MKL_THREADING_LAYER=GNU" in your environement”然后
转到“控制面板”>“系统”>“高级系统设置”,然后选择“环境变量” .
在"System variables"部分中,创建一个新变量名
MKL_THREADING_LAYER
并将其值设置为GPU
如果您遇到其他类型的错误,请尝试以下操作:
在主文件夹C:\ Users \ <用户名>中创建一个名为
.theanorc
(没有文件名的文件扩展名)的空文件 . 如果您收到错误"You must type a file name",请参阅stackoverflow.com/q/5004633打开
.theanorc
并写下:.theanorc