Boost logo

Boost Users :

Subject: [Boost-users] [python::numpy] Access Violation when initializing numpy
From: Christian Henning (chhenning_at_[hidden])
Date: 2017-11-18 16:52:41


Hi all,

On Windows 10 with Visual Studio 2017 I', trying to run the following code
in x64 debug configuration:

#include <iostream>

#include <boost/python.hpp>
#include <boost/python/numpy.hpp>

namespace p = boost::python;
namespace np = boost::python::numpy;

int main()
{
    Py_Initialize();
    np::initialize();

    p::tuple shape = p::make_tuple(3, 3);
    np::dtype dtype = np::dtype::get_builtin<float>();
    np::ndarray a = np::zeros(shape, dtype);

    return 0;
}

In the line

np::initialize();

I'm getting a

Exception thrown at 0x0000000066E43B15 (python36.dll) in test.exe:
0xC0000005: Access violation reading location 0x0000000000000025. occurred

Inside boost::python::numpy::intialize() the exception is thrown when
trying to execute the line:

PyObject *numpy = PyImport_ImportModule("numpy.core.multiarray");

Does anyone know why that would happen or how to debug the issue further?

I have installed all packages via pip and executed the python code as
described in https://www.scipy.org/getting-started.html.

Thanks ahead!
Christian



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net