SolvedTheano I'm getting an ImportError in Theano in Anaconda

When I import keras or theano after downloading it with Anaconda, I get this error.

F:\Anaconda>python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 07:29:16) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import keras
Using Theano backend.

You can find the C code in this temporary file: C:\Users\JSI-NU~1\AppData\Local\Temp\theano_compilation_error_5fye1oej
Traceback (most recent call last):
File "F:\Anaconda\lib\site-packages\theano\gof\lazylinker_c.py", line 75, in
raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "F:\Anaconda\lib\site-packages\theano\gof\lazylinker_c.py", line 92, in
raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "F:\Anaconda\lib\site-packages\keras_init_.py", line 3, in
from . import utils
File "F:\Anaconda\lib\site-packages\keras\utils_init_.py", line 6, in
from . import conv_utils
File "F:\Anaconda\lib\site-packages\keras\utils\conv_utils.py", line 3, in
from .. import backend as K
File "F:\Anaconda\lib\site-packages\keras\backend_init_.py", line 80, in
from .theano_backend import *
File "F:\Anaconda\lib\site-packages\keras\backend\theano_backend.py", line 3, in
import theano
File "F:\Anaconda\lib\site-packages\theano_init_.py", line 110, in
from theano.compile import (
File "F:\Anaconda\lib\site-packages\theano\compile_init_.py", line 12, in
from theano.compile.mode import *
File "F:\Anaconda\lib\site-packages\theano\compile\mode.py", line 11, in
import theano.gof.vm
File "F:\Anaconda\lib\site-packages\theano\gof\vm.py", line 673, in
from . import lazylinker_c
File "F:\Anaconda\lib\site-packages\theano\gof\lazylinker_c.py", line 127, in
preargs=args)
File "F:\Anaconda\lib\site-packages\theano\gof\cmodule.py", line 2356, in compile_str
(status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): C:\Users\JSI-NU1\AppData\Local\Temp\ccAbnd1v.o: In function import_ar. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1460: undefined reference to _imp__PyExc_Im. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1466: undefined reference to _imp__PyExc_At. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1471: undefined reference to _imp__PyCapsul. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1472: undefined reference to _imp__PyExc_Ru. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1487: undefined reference to _imp__PyExc_Ru. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1495: undefined reference to _imp__PyExc_Ru. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1501: undefined reference to _imp__PyExc_Ru. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_api.h:1511: undefined reference to _imp__PyExc_Ru. C:\Users\JSI-NU~1\AppData\Local\Temp\ccAbnd1v.o:F:/Anaconda/lib/site-packages/numpy/core/include/numpy/__multiarray_ap. F:/Anaconda/lib/site-packages/numpy/core/include/numpy/npy_3kcompat.h:456: undefined reference to _imp__PyCapsule_Typ. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:\Users\JSI-NU1\AppData\Local\Temp\ccAbnd1v.o:C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_GenuineIntel-3.6.3-32/lazylinker_ext/mod.cpp:393: more undefined references to. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:\Users\JSI-NU1\AppData\Local\Temp\ccAbnd1v.o:C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_GenuineIntel-3.6.3-32/lazylinker_ext/mod.cpp:546: more undefined references to. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:\Users\JSI-NU1\AppData\Local\Temp\ccAbnd1v.o:C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_GenuineIntel-3.6.3-32/lazylinker_ext/mod.cpp:850: more undefined references to. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. C:/Users/jsi-nupita/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-x86_Family_6_Model_23_Stepping_10_Genuin. collect2.exe: error: ld returned 1 exit statusfined reference to `_imp___Py_TrueStruct'

What does it mean? I'm using a 32-bit Windows 10 Dell Computer

19 Answers

✔️Accepted Answer

Finally got rid of the warning with:

sudo apt install libblas-dev

Other Answers:

Hi:

  • Have you installed the conda package libpython ?
  • which version of GCC do you use (what is the output of gcc -v) ? The recommended version for Windows is the one provided in conda package m2w64-toolchain.
  • Also, as you seems to use Aanaconda, make sure you always install the conda version of any module you use (conda install <module>/conda remove <module>) instead of the PyPI version (pip install <module> / pip uninstall <module>).

Could you make sure the following conda packages are installed, then clear the theano cache (theano-cache purge) and retry ?

conda install numpy scipy mkl-service libpython m2w64-toolchain