在windows下从cmd窗口 进入到 cython 包目录
运行 python setup.py build
结果报错: error: Unable to find vcvarsall.bat
然后换做运行: python setup.py build --compiler=mingw32
[
或者在 python安装目录下: python\Lib\distutils\新建 distutils.cfg
里面加上:
compiler=mingw32
[build_ext]
compiler = mingw32
再调用 python setup.py build
]
又报错: error: comand "gcc" failed with exit status 1
进入python安装目录里的 python\Lib\distutils\cygwinccompiler.py,把里面的-mno-cygwin 相关的参数去掉
再次运行: python setup.py build --compiler=mingw32
好了,这次创建成功了。
可以直接下载安装 windows 二进制包
http://www.lfd.uci.edu/~gohlke/pythonlibs/#cython
教程中的这段代码有问题(来自:http://docs.cython.org/src/userguide/language_basics.html):
struct Spam:
int tons
int i
float f
Spam *p
void f(Spam *s):
print s.tons, " Tons of spam "
用 python setup.py build_ext --inplace 编译 回报:
Function signature does not match previous declaration 的错误
原因在于 定义的变量名和函数名在同一个域中重名