Skip to content Skip to sidebar Skip to footer

Boost Python - Nullptr While Extracting Ndarray

I have a C++ code which execute python script with boost_python package. Everything is fine, as longa as I extract int, string, or other not-array variables from python. However I

Solution 1:

That error occurs since you're using the numpy module without first initializing it.

Notice the beginning of the official tutorial:

Initialise the Python runtime, and the numpy module. Failure to call these results in segmentation errors:

namespace np = boost::python::numpy;
int main(int argc, char **argv)
{
  Py_Initialize();
  np::initialize();

Your code is lacking the call to np::initialize();.


Post a Comment for "Boost Python - Nullptr While Extracting Ndarray"