Segmentation Fault calling Numpys import_array on Mac M1

Viewed 116

for an application I am trying to use NumPy from C++ on a Mac M1. Unfortunately I get a segmentation fault when calling import_array(). My small test program looks like this:

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <Python.h>
#include <numpy/arrayobject.h>

int
main(int argc, char *argv[])
{
     import_array();
     if (PyErr_Occurred()) {
         std::cerr << "Failed to import numpy Python module(s)." << std::endl;
         return 0;
     }
    return 0;
}

More precisely, the error occurs when calling 'PyImport_ImportModule("numpy.core._multiarray_umath")' in __multiarray_api.h. Strangely, no problem exists when importing _multiarray_umath in Python. Both Python and NumPy are versions for arm64.

I've tried Clang and GCC for compilation. Did anyone have the same problem and a solution or an idea what I could try?

0 Answers
Related