Hi I\'m trying to embed python (2.7) into C++ (g++ 4.8.2) and hence call a python function from C++. This is the basic code provided in python documentation for embedding:
the solution provided by spinus works if the python file does not import any additional python-library.
However, if a python file imports an additional library, lets say numpy, the above code crashes as follows:
:~/programs/python$ ./a.out myModule multiply 4 3
Traceback (most recent call last):
File "/home/a/programs/python/myModule.py", line 1, in
import numpy
ImportError: No module named 'numpy'
Failed to load "myModule"
As a remark, the import of the python-library from C does not work:
PyObject *pNumpy = PyUnicode_FromString("numpy");
PyObject *pModuleA = PyImport_Import(pNumpy);
Does someone know how to call from C python-functions, which depend of some other python-libraries?