问题
I am trying out boost-python. However, even a simple hello world doesn't work.
#define BOOST_PYTHON_STATIC_LIB
#include <boost/python/detail/wrap_python.hpp>
#include "numpy/arrayobject.h"
#include <boost/python.hpp>
void init_numpy()
{
import_array();
}
int main()
{
Py_Intialize();
init_numpy();
}
It gives error
ImportError: numpy.core.multiarray failed to import
But if I open my IPython, and run import numpy.core.multiarray
, it runs fine. What part am I getting worng?
回答1:
I solved the problem by by realizing that the Anaconda2 on my windows was not registered during installation (even sys.path
is the same as that in IPython), I uninstalled it and reinstalled it, during installation I chose to register in the windows, now my code is working fine.
来源:https://stackoverflow.com/questions/42938191/can-not-import-numpy-in-boost-python