g++ error on import of Theano on Windows 7

╄→гoц情女王★ 提交于 2019-11-29 03:08:31

问题


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.


回答1:


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
    



回答2:


"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




回答3:


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}



回答4:


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




回答5:


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")



回答6:


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


来源:https://stackoverflow.com/questions/38536788/g-error-on-import-of-theano-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!