Python Embedding in C++ : ImportError: No module named pyfunction

后端 未结 6 699
栀梦
栀梦 2021-02-07 11:32

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:

6条回答
  •  萌比男神i
    2021-02-07 11:58

    You can also try to include these code to your c program

    Py_Initialize();
    PyObject *sys = PyImport_ImportModule("sys");
    PyObject *path = PyObject_GetAttrString(sys, "path");
    PyList_Append(path, PyUnicode_FromString("."));
    

    Learn from Here

提交回复
热议问题