gpt4 book ai didi

deep-learning - Theano:AttributeError:模块 'theano'没有属性 'gof'

转载 作者:行者123 更新时间:2023-12-04 03:48:22 26 4
gpt4 key购买 nike

该线程中提出的解决方案对我不起作用:

Import theano gives the AttributeError: module 'theano' has no attribute 'gof'

我试过conda install theano (对于 jupyter notebook),尽管安装完美,但我仍然收到上述错误。

我正在使用 Python 3.6、Windows 7、Anaconda/Jupyter 笔记本和 Nvidia 1070 GPU。 Theano 是 .9.0 版本

回溯如下:

ImportError                               Traceback (most recent call last)
C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
74 if version != getattr(lazylinker_ext, '_version', None):
---> 75 raise ImportError()
76 except ImportError:

ImportError:

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
91 if version != getattr(lazylinker_ext, '_version', None):
---> 92 raise ImportError()
93 except ImportError:

ImportError:

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)
C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\gof\vm.py in <module>()
661 raise theano.gof.cmodule.MissingGXX('lazylinker will not be imported if theano.config.cxx is not set.')
--> 662 from . import lazylinker_c
663

C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
126 cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 127 preargs=args)
128 # Save version into the __init__.py file.

C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\gof\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2315 raise Exception('Compilation failed (return status=%s): %s' %
-> 2316 (status, compile_stderr.replace('\n', '. ')))
2317 elif config.cmodule.compilation_warning and compile_stderr:

Exception: Compilation failed (return status=1): In file included from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/Python.h:50:0,. from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:1:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/pyport.h:686:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).". #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).". ^. In file included from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/Python.h:133:0,. from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:1:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:23:5: error: '__int64' does not name a type. __int64 st_ino;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:29:5: error: '__int64' does not name a type. __int64 st_size;. ^. In file included from /usr/include/sys/stat.h:22:0,. from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/pyport.h:227,. from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/Python.h:50,. from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:1:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:30:12: error: expected ';' at end of member declaration. time_t st_atime;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:30:12: error: expected unqualified-id before '.' token. time_t st_atime;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:32:12: error: expected ';' at end of member declaration. time_t st_mtime;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:32:12: error: expected unqualified-id before '.' token. time_t st_mtime;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:34:12: error: expected ';' at end of member declaration. time_t st_ctime;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/fileutils.h:34:12: error: expected unqualified-id before '.' token. time_t st_ctime;. ^. In file included from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/Python.h:8:0,. from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:1:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\include/pyconfig.h:269:23: error: '__int64' does not name a type. # define PY_LONG_LONG __int64. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_common.h:309:9: note: in expansion of macro 'PY_LONG_LONG'. typedef PY_LONG_LONG npy_longlong;. ^. In file included from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_3kcompat.h:22:0,. from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:7:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_common.h:310:31: error: expected initializer before 'npy_ulonglong'. typedef unsigned PY_LONG_LONG npy_ulonglong;. ^. In file included from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_3kcompat.h:22:0,. from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:7:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_common.h:611:17: error: 'npy_longlong' does not name a type. typedef npy_longlong npy_int64;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_common.h:612:17: error: 'npy_ulonglong' does not name a type. typedef npy_ulonglong npy_uint64;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_common.h:1090:9: error: 'npy_int64' does not name a type. typedef npy_int64 npy_timedelta;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_common.h:1091:9: error: 'npy_int64' does not name a type. typedef npy_int64 npy_datetime;. ^. In file included from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:18:0,. from C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_3kcompat.h:23,. from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:7:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:742:9: error: 'npy_int64' does not name a type. npy_int64 year;. ^. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:748:9: error: 'npy_int64' does not name a type. npy_int64 day;. ^. In file included from C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.6.0-64\lazylinker_ext\mod.cpp:7:0:. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_3kcompat.h: In function 'int npy_PyFile_DupClose2(PyObject*, FILE*, off_t)':. C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\include/numpy/npy_3kcompat.h:274:41: error: 'lseek' was not declared in this scope. if (npy_lseek(fd, orig_pos, SEEK_SET) == -1) {. ^.

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
<ipython-input-6-3397704bd624> in <module>()
----> 1 import theano

C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\__init__.py in <module>()
64 object2, utils)
65
---> 66 from theano.compile import (
67 SymbolicInput, In,
68 SymbolicOutput, Out,

C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\compile\__init__.py in <module>()
8 SpecifyShape, specify_shape, register_specify_shape_c_code)
9
---> 10 from theano.compile.function_module import *
11
12 from theano.compile.mode import *

C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\compile\function_module.py in <module>()
19 from theano.compat import izip
20 from theano.gof import graph
---> 21 import theano.compile.mode
22 import theano.compile.profiling
23 from theano.compile.io import (

C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\compile\mode.py in <module>()
8 import theano
9 from theano import gof
---> 10 import theano.gof.vm
11 from theano.configparser import config
12 from theano.compile.ops import _output_guard

C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\gof\vm.py in <module>()
669 except ImportError:
670 pass
--> 671 except (OSError, theano.gof.cmodule.MissingGXX) as e:
672 # OSError happens when g++ is not installed. In that case, we
673 # already changed the default linker to something else then CVM.

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

更新:

我使用 pip3.6 和 conda 卸载了 theano (我有两个版本),然后重新安装 conda install theano
现在我收到此错误:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-3397704bd624> in <module>()
----> 1 import theano

ModuleNotFoundError: No module named 'theano'

也尝试重新启动 Jupyter 笔记本,得到 No module named 'theano'
编辑:
重装了几次theano。我什至重新启动了我的电脑。
还是有这个问题。

我看到了 theanosite-packages anaconda 文件夹中的文件夹。
所以不明白是什么问题。

问题又回到了:
AttributeError: module 'theano' has no attribute 'gof'
谢谢你。

最佳答案

对我来说,这是一个 numpy 版本问题。一旦我将我的 numpy 重新安装到 1.13.1 版,它就可以工作了。

注意:确保以兼容的方式更新其他依赖于 numpy 的包,例如 Scikit-learn 等。最好的方法是为深度学习创建一个环境。

关于deep-learning - Theano:AttributeError:模块 'theano'没有属性 'gof',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44103230/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com