[Numpy-discussion] embedding numpy ImportError: numpy.core.multiarray failed to import

Sunghwan Choi sunghwanchoi91@gmail....
Wed Mar 6 06:22:23 CST 2013


Hi, 

I tried to embedding numpy in C++ but I got 

ImportError: numpy.core.multiarray failed to import

Do you know any ways to solve this problem?

I copy my codes and error message 

 

 

Makefile

 

CXX= icpc

all: exe

clean:

    rm -rf *.o exe

exe: test.o

    $(CXX) -o exe test.o -L/home/shchoi/program/epd/lib/ -lpython2.7 

test.o : test.cpp

    $(CXX) -c test.cpp
-I/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/core/include/nu
mpy/ -I/home/shchoi/program/epd/include/python2.7

 

tmp.cpp

 

#include "Python.h"

#include "arrayobject.h"

#include <stdio.h>

#include <iostream>

extern "C" void Py_Initialize();

extern "C" void PyErr_Print();

using namespace std;

 

int main(int argc, char* argv[])

{

    double answer = 0;

    PyObject *modname, *mod, *mdict, *func, *stringarg, *args, *rslt;

 

    Py_Initialize();

    import_array();

    modname = PyString_FromString("numpy");

    mod = PyImport_Import(modname);

    PyErr_Print();

    cout << mod << endl;

    Py_Finalize();

    return 0;

}

 

 

 

 

$ make

icpc -c test.cpp
-I/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/core/include/nu
mpy/ -I/home/shchoi/program/epd/include/python2.7

test.cpp(15): warning #117: non-void function "main" should return a value

          import_array();

          ^

icpc -o exe test.o -L/home/shchoi/program/epd/lib/ -lpython2.7
#-L/home/shchoi/program/epd/lib/python2.7/site-packages/numpy/core/

 

$ ./exe 

ImportError: numpy.core.multiarray failed to import

 

 

 

Sunghwan Choi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130306/0fe109f1/attachment-0001.html 


More information about the NumPy-Discussion mailing list