1

To include C extensions, the setup.py to build my repo looks like:

import numpy as np
from setuptools import setup, Extension

setup(
    ext_modules=[
        Extension("my_module", 
                  sources=["my_module.cc"],
                  include_dirs=[np.get_include()]),
    ],
)

but despite including the path to the numpy headers, running python setup.py install results in the error fatal error: 'arrayobject.h' file not found because my_module.cc has #include <arrayobject.h>.

I've gone through dozens of related SO and GitHub issues, all suggesting the include_dirs=[np.get_include()] workaround I've already implemented. The numpy path is /usr/local/lib/python2.7/site-packages/numpy/core/include/, and yes I've confirmed the headers are indeed there.

Any suggestions?

1 Answer 1

1

On my system the header file is at /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h, so the solution is to instead do include_dirs=[os.path.join(np.get_include(), 'numpy')].

Sign up to request clarification or add additional context in comments.

1 Comment

Alternatively, in the C file specify #include "numpy/arrayobject.h"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.