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

后端 未结 6 625
栀梦
栀梦 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:51

    For anyone else having this problem:

    Are you sure that your .py file lies in the same directory where C++ executable is?

    I was programming in CLion and forgot that executable lies in cmake-build-debug. So I added .py file in project directory and no no surprise I was getting the same error ImportError. I placed .py file to cmake-build-debug (executable file by default lies there), used answers from this question and everything worked!

提交回复
热议问题