从 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 上运行