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

后端 未结 6 623
栀梦
栀梦 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条回答
  •  梦谈多话
    2021-02-07 11:59

    Hi to all those facing the same problem, I found the solution! setenv() is a function defined in stdlib.h which sets the environment variable. Just have to run it!

    setenv("PYTHONPATH",".",1);
    

    for more info on setenv:

    $ man setenv
    

    All the best :) Also, thanks to @spinus

提交回复
热议问题