Error importing theano "cannot import name gof"

Huynh Vu picture Huynh Vu · Jul 16, 2015 · Viewed 14.7k times · Source

I am current getting the error

ImportError: cannot import name gof

when importing 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

I am using python 2.7.10 (). Theano is installed using pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git. Hope to get you suggestion to solve this problem

Answer

nouiz picture nouiz · Jul 21, 2015

Most of the time, when I see this error, it is caused by those 2 errors:

1) A syntax error in Theano. Update Theano and make sure to have no local modifcation. I nerver saw this error in the master of Theano, but just in case.

2) When there is multiple version of Theano that are installed.

In both case, remove all version of Theano. Do it multiple time to be sure there is none left. Then install again.

From memory, this always solved the problem when it wasn't a syntax error during development (but not in the master version of Theano that you use)