2017-05-22 1 views
2

La solution présentée dans ce fil ne fonctionne pas pour moi:Théano: AttributeError: module 'Théano' n'a pas d'attribut 'GOF'

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

J'ai essayé conda install theano (pour ordinateur jupyter) et malgré l'installation parfaitement je reçois toujours l'erreur ci-dessus. J'utilise un ordinateur portable Python 3.6, Windows 7, Anaconda/Jupyter avec un GPU Nvidia 1070. Théano est une version .9.0

Le retraçage est la suivante:

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' 

MISE À JOUR:

Je désinstallés Théano en utilisant pip3.6 et Conda (j'ai eu deux versions), puis réinstallé avec conda install theano

maintenant que je reçois cette erreur:

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

ModuleNotFoundError: No module named 'theano' 

Essayé de redémarrer le portable Jupyter, obtenant ainsi le No module named 'theano'

EDIT: Réinstallé plusieurs fois. J'ai même redémarré mon ordinateur. Vous rencontrez toujours ce problème. Je vois theano dans le dossier site-packages dans le dossier anaconda. Donc ne pas comprendre quel est le problème.

Le problème a été retourné à:

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

Merci.

+0

Pour le « aucun module nommé GOF », avez-vous importez Théano dans son propre répertoire? C'est interdit. Pour le "aucun module nommé theano", quel interpréteur est lié à votre ipython, est-ce le système par défaut ou anaconda? – Kh40tiK

+0

Merci pour le commentaire. Non, je n'importe pas depuis l'intérieur de son propre répertoire. Je suis dans le répertoire 'C: \ Users \ Username' et Theano est installé dans le sous-répertoire d'Anaconda. 'C: \ Utilisateurs \ Nom d'utilisateur \ quelquechose \ Anaconda \' # 2 En ce qui concerne votre deuxième question, si j'exécute iPython, je vois python 2.7 dans les premières lignes. Donc je suppose qu'il est attaché à défaut et pas anaconda? Cependant, le Python par défaut de mon Anaconda est la version 3.6 – Moondra

Répondre

1

Pour moi, c'était un problème de version numpy. Une fois que j'ai réinstallé mon numpy à la version 1.13.1, cela a fonctionné.

Note: Assurez-vous de mettre à jour également les autres paquets qui dépendent de numpy tels que Scikit-learn, etc de manière à être compatibles. Le meilleur moyen est de créer un env juste pour un apprentissage en profondeur.

1

Pour moi, c'était un problème de compilateur qui résultait d'une mauvaise version (inattendue) g++ utilisée pour la compilation.

En plus du paquet m2w64-toolchain (qui comprend un compilateur g++ qui est « fortement recommandé » pour une utilisation avec Théano, voir installation instructions), j'avais une instance Cygwin installé dont g++.exe a été souligné dans PATH de système Windows variable. Au cours de import theano, la version cygwin a été utilisée à la place de la version m2w64-toolchain.

Voir aussi cette discussion où j'ai trouvé la solution: https://github.com/Theano/Theano/issues/6004