Jwely
Jwely

Reputation: 731

g++ error on import of Theano on Windows 7

I'm attempting to get setup with a proper g++ installation according to the theano installation guide. I've previously had theano working with the python only implementation. I'm using the bleeding edge version of theano from their git repo on python 3.4. I've tried using the theano suggested TDM-GCC-64 method as well as MinGW, and both result in the exact same error. (copied as readable as possible)

Problem occurred during compilation with the command line below:
C:\MinGW\bin\g++.exe -shared -g -march=skylake -mmmx -mno-3dnow -msse -msse2 -msse3 
-mssse3 -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt 
-mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mavx 
-mavx2 -msse4.2 -msse4.1 -mlzcnt -mrtm -mhle -mrdrnd -mf16c -mfsgsbase 
-mrdseed -mprfchw -madx -mfxsr -mxsave -mxsaveopt -mno-avx512f 
-mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mclflushopt 
-mxsavec -mxsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl 
-mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-pcommit -mno-mwaitx 
-mno-clzero -mno-pku --param l1-cache-size=32 --param 
l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=skylake 
-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 
-IC:\Python34_64bit\lib\site-packages\numpy\core\include
IC:\Python34_64bit\include -IC:\Python34_64bit\lib\site-packages\theano\gof
-o C:\Users\Jwely\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.4.4-64\lazylinker_ext\lazylinker_ext.pyd 
C:\Users\Jwely\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.4.4-64\lazylinker_ext\mod.cpp 
-LC:\Python34_64bit\libs -LC:\Python34_64bit -lpython34


In file included from c:\mingw\include\c++\6.1.0\math.h:36:0,
from C:\Python34_64bit\include/pyport.h:328,
from C:\Python34_64bit\include/Python.h:50,
from C:\Users\Jwely\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.4.4-64\lazylinker_ext\mod.cpp:1:
c:\mingw\include\c++\6.1.0\cmath:1133:11: error: '::hypot' has not been declared
    using ::hypot;
            ^~~~~

It may be worth noting that before it prints this error, it prints an entire file worth of code, you can find the entire error output here

I'm not sure what to try next, I've followed the directions twice, used a couple different installation methods for some dependencies, and made sure to clean up my system path between each attempt and reboot.

Upvotes: 8

Views: 6054

Answers (6)

Farshid Shekari
Farshid Shekari

Reputation: 2449

if you can't create a file with name .theanorc.
You can use this code in console but before open cmd in C:/Users/[username] and then write python and then paste below code there:

import os
with open(os.path.join(os.environ["USERPROFILE"], ".theanorc"), "w") as f:
    f.write("[gcc]\ncxxflags = -D_hypot=hypot")

Upvotes: 0

Saleh Ragab
Saleh Ragab

Reputation: 1

First, uninstall all Theano versions.

Then:

pip install pydot-ng

conda install mingw libpython

pip install git+https://github.com/Theano/Theano.git#egg=Theano

Upvotes: -1

4Oh4
4Oh4

Reputation: 2171

The answers above are probably a better, more permanent solution. For a quick fix, the following worked for me:

import theano
theano.config.gcc.cxxflags = "-D_hypot=hypot"

...with Windows 10, Anaconda 4.4, Python 2.7, Theano v0.10.0.dev1, m2w64-toolchain v5.3.0

Upvotes: 0

Steve
Steve

Reputation: 142

This worked for me

  1. Go to System properties/Advance system setting
  2. Add your MinGW installation path, if already added and looks something like C:\{your MingW installation}\bin change it to C:\{your MingW installation}

Upvotes: 0

Alex
Alex

Reputation: 759

This worked for me:

  1. Go to your user folder: C:/Users/[username]
  2. Create .theanorc file if it doesn't already exist
  3. makes sure it includes the lines:

    [gcc]
    cxxflags = -D_hypot=hypot
    

Upvotes: 29

ZornLemma
ZornLemma

Reputation: 51

"Error: '::hypot' has not been declared" in cmath while trying to embed Python Error building Boost 1.49.0 with GCC 4.7.0

my solution is comment out all the

#define hypot _hypot

macro in the pyconfig.h file

Upvotes: 4

Related Questions