[Cython] Cython and Numpy

Dag Sverre Seljebotn dagss at student.matnat.uio.no
Tue Jun 16 15:07:48 CEST 2009


Brett Calcott wrote:
> Hi Daniel,
> 
> 
> 2009/6/16 Daniel Yarlett <daniel.yarlett at gmail.com>:
>> ... SNIP ...
>> It looks like arrayobject.h is not being found, so do I need to modify
>> my setup.py file somehow? I'm afraid I'm not sure how to do this, so
>> any help would be greatly appreciated.
> 
> 
> This line in my .bashrc solves the same problem on my Mac
> 
> export C_INCLUDE_PATH=/Library/Python/2.5/site-packages/numpy/core/include
> 
> Or, I think you could add the same path to your definition of the
> Extension() in setup.py. I think you can do this:
> 
> ext_modules = [Extension("neuralRoutines", ["neuralRoutines.pyx"],
>         extra_compile_args=['-Ithe/path/you/want/here'],
> )]
> 
> ... but I haven't checked it.

The usual way of doing this is

import numpy
...
setup(
    ...
    ext_modules = [Extension(..., include_path=[numpy.get_include()])]
)

No need to alter include paths etc. then.

(It would be great if somebody could take the time to add this question 
to the FAQ and/or the Cython/NumPy tutorial, it comes up a lot.)

-- 
Dag Sverre


More information about the Cython-dev mailing list