Install Theano under Anaconda3 Python 3.5

This post was kindly contributed by SAS Programming for Data Mining - go there to comment and to read the full post.

As of writing, Deep Learning package Theano can’t be installed under Python 3.5, which causes some problems with my project. ruslanagit provided a viable solution that works for me under Windows 10.

For convenience, I copied his solution below:

Well, the main problem with Python 3.5 on windows, I guess, is that mingw and libpython are not available (not complied with Python 3.5), so you cannot run $ conda install mingw libpython step.

So you either need to downgrade to Python 3.4 (was not an option for me) and then follow standard instructions for installing Theano on Windows, or make a few tricks to make theano work with Python 3.5. For me the following steps worked on Windows 10 with Anaconda3 and Python 3.5:

  • Install mingw from https://sourceforge.net/projects/mingw-w64/ 
  • Add the bin directory of mingw to PATH, and make sure there is no other gcc compiler in PATH (i.e. TDM-GCC is not there). 
  • In .theanorc file add 

 [gcc]
cxxflags = -shared -I”[TDM-GCC path]\include” -I”[TDM-GCC path]\x86_64-w64-mingw32\include”

You should update paths to TDM-GCC according to your system. Note, that TDM include directory is required, since the compilation will fail with mingw include directories for python 3.5 (I think they would work for Python 2, but I am not 100% sure)

  • Create libpython35.a manually and copy it to appropriate directory. For example: 
    • Create temp directory 
    • Copy python35.dll (I took it from Anaconda3 folder) into created directory 
    • Navigate into created directory 
    • Run: gendef python35.dll 
    • Run: dlltool –dllname python35.dll –def python35.def –output-lib libpython35.a 
    • Copy libpython35.a into Anaconda3\libs 
    • All other installations/configurations were done as described in the guide for installaing Theano on Windows.

This post was kindly contributed by SAS Programming for Data Mining - go there to comment and to read the full post.