Ok, I figured it out. I had two sets of python libs installed, via the Windows python installer and via vcpkg.

I hope the following items might help someone:

* the default python installation on Windows already comes with import libs and the dlls.
* there is no need to built python with vcpkg not even for debug configuration
* DONT set BOOST_DEBUG_PYTHON unless you want to debug python libs
* Ideally, there is no need to set PYTHONHOME and PYTHONPATH environmental variables.

Regards,
Christian



On Sat, Nov 18, 2017 at 11:52 AM, Christian Henning <chhenning@gmail.com> wrote:
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