相关疑难解决方法(0)

让distutils在正确的位置查找numpy头文件

在我的安装中,numpy arrayobject.h位于…/site-packages/numpy/core/include/numpy/arrayobject.h.我写了一个使用numpy的简单Cython脚本:

cimport numpy as np

def say_hello_to(name):
    print("Hello %s!" % name)
Run Code Online (Sandbox Code Playgroud)

我也有以下distutils setup.py(从Cython用户指南复制):

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

ext_modules = [Extension("hello", ["hello.pyx"])]

setup(
  name = 'Hello world app',
  cmdclass = {'build_ext': build_ext},
  ext_modules = ext_modules
)
Run Code Online (Sandbox Code Playgroud)

当我尝试构建时python setup.py build_ext --inplace,Cython尝试执行以下操作:

gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd \
-fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX \
-I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe \
-I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 …
Run Code Online (Sandbox Code Playgroud)

python distutils numpy cython

42
推荐指数
2
解决办法
2万
查看次数

标签 统计

cython ×1

distutils ×1

numpy ×1

python ×1