squirrel2300

导航

python 3.5 import theano ::hypot error

# win10 , mingw(nuwen,g++ 6.3), python 3.5 ,

描述:

import theano 时生成动态的 mod.cpp ,然后编译库的时候报 ::hypot 未定义

原因:

hypot 在"C:\Program Files\Python35\include\pyconfig.h"被重定义了

pyconfig.h

-------------------------------------------

#define hypot _hypot

-------------------------------------------

解决思路:

在import theano 调用 g++ 编译mod.cpp的时候添加编译参数  -D_hypot=hypot

实现:

有多种方法可行,例如给 theano 添加配置文件等。

一种实际操作方法:

搜索 theano 文件夹下面含有编译参数字符串的文件,然后在某个编译参数后面加上 -D_hypot=hypot

例如:

cc.py      "C:\Program Files\Python35\Lib\site-packages\theano\gof\cc.py"

-------------------------------------------

def compile_args(self):

...

"-Wno-write-strings",  # generated by our code generator...
"-D_hypot=hypot",
]

-------------------------------------------

cmodule.py   "C:\Program Files\Python35\Lib\site-packages\theano\gof\cmodule.py"

-------------------------------------------

def get_gcc_shared_library_arg():

...

return '-shared -D_hypot=hypot'

-------------------------------------------

 

posted on 2017-05-17 16:20  squirrel2300  阅读(367)  评论(0编辑  收藏  举报