【发布时间】:2013-10-04 03:29:07
【问题描述】:
从 enthought 安装的顶篷。在构建我的 .pyx 文件时,我收到此错误(后跟更多)
我是否需要 easy_install 额外的软件包才能获得“开发”版本,以便获得 .h 文件?
gcc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -DNDEBUG -g -O3 -arch x86_64 -I/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/include/python2.7 -c tsBinner.c -o build/temp.macosx-10.6-x86_64-2.7/tsBinner.o
tsBinner.c:314:31: error: numpy/arrayobject.h: No such file or directory
tsBinner.c:315:31: error: numpy/ufuncobject.h: No such file or directory
更多上下文
这可以在多个 Linux 安装下编译和运行,但不适用于我最近安装的 Canopy 发行版 python
这里是 setup.py 的内容
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("tsBinner",["tsBinner.pyx"])]
setup(
name ='time stamp binner',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
这是tsBinner.py的内容
from __future__ import division
import numpy as np
cimport numpy as np
#cimport cython
#@cython.boundscheck(False)
def tsBinner(np.ndarray[np.uint64_t, ndim=1] tstamps, \
np.ndarray[np.int_t, ndim=1] bins):
"""
bin the values of the tstamps array into the bins array.
tstamps array is of type np.uint64
bins array is of type int
"""
cdef int nTStamps = tstamps.shape[0]
cdef int iTStamp
for iTStamp in range(nTStamps):
bins[tstamps[iTStamp]] += 1
return
这里是python和gcc的版本
mac-119562:cosmic stoughto$ which python
/Users/stoughto/Library/Enthought/Canopy_64bit/User/bin/python
mac-119562:cosmic stoughto$ which gcc
/usr/bin/gcc
mac-119562:cosmic stoughto$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
mac-119562:cosmic stoughto$ python --version
Python 2.7.3 -- 64-bit
在 MacBook Pro Mac OS X 版本 10.7.5 上运行
【问题讨论】:
-
更多上下文会更好。
-
我遇到了同样的问题,你还必须在你的 gcc 命令中包含
-I.../site-packages/numpy/core/include... -
你可以尝试从
numpy.distutils.core而不是distutils.core导入,不知道会不会有什么不同。 -
Jaime,抱歉更改导入无效。
-
Saullo,谢谢,这有帮助。我通过在运行命令“python setup.py buils_ext --inplace”命令之前将环境变量 CPATH 设置为 /Users/.../site-packages/numpy/core 来做到这一点。有没有办法包含逻辑(在 setup.py 中?)以使其更便携?