Toht
Toht

Reputation: 63

Sympy's autowrap with cython and Matrix generates fatal error: 'numpy/arrayobject.h' file not found

I'm trying to execute the simple example from the Sympy's autowrap module that includes matrix/vector product with the Cython langage (since I do not have gfortran installed):

import sympy.utilities.autowrap as aw
from sympy.utilities.autowrap import autowrap
from sympy import symbols, IndexedBase, Idx, Eq
A, x, y = map(IndexedBase, ['A', 'x', 'y'])
m, n = symbols('m n', integer=True)
i = Idx('i', m)
j = Idx('j', n)
instruction = Eq(y[i], A[i, j]*x[j])
matvec = autowrap(instruction, language='C',backend='cython')               

I'm on OSX 10.9.4, with the anaconda distribution for python 2.7, sympy 0.7.6.1 and cython 0.23.2.

I get the following (known) error: fatal error: 'numpy/arrayobject.h' file not found

It seems to be a systematic error, and one needs to include the appropriate numpy's header target in the setup file attached to the compilation process of cython as suggested here.

How to get rid form this issue in an autowrap context? It seems this is a bug fixed here, but it does not work for me... Is this bug fix included in sympy's realease 0.7.6.1? Any idea?

Upvotes: 1

Views: 243

Answers (1)

moorepants
moorepants

Reputation: 1869

This was a bug and is now fixed. See this pull request:

https://github.com/sympy/sympy/pull/8848

If you use the development version of SymPy, it should work. Else you could have autowrap spit the files out to a temporary directory, add the correct include statement to the generated files, and manually compile the code.

Upvotes: 1

Related Questions