How to embed Python3 with the standard library

前端 未结 3 1021
花落未央
花落未央 2021-02-07 17:10

I am attempting to embed Python in an (ultimately multiplatform) C++ app.

It\'s important that my app contains its own Python implementation (in the same way that blend

3条回答
  •  遇见更好的自我
    2021-02-07 17:52

    I suppose that you have already double check how to Embedding Python in Another Application (here you will see something which cover embedding python2 but will be true for python3 also in my opinion)

    There is different types of embedding:

    • Very High Level Embedding
    • Beyond Very High Level Embedding
    • Pure Embedding
    • Embedding Python in C++

    As your question is relative to "Embedding Python in C++" you may read this:

    It is also possible to embed Python in a C++ program; precisely how this is done will depend on the details of the C++ system used; in general you will need to write the main program in C++, and use the C++ compiler to compile and link your program. There is no need to recompile Python itself using C++.

    As one hand you said "(ultimately multiplatform) C++ app", and in the other hand you have "precisely how this is done will depend on the details of the C++ system used", so may you explain more details of the C++ system used ?

    You may also find some tips here relative to the use of pybind11 module or another old page which treat about how to Embed Python and Import Modules in C/C++ (python2.6 but I hope you may found inspiration with)

    To conclude:

    You'll obviously need development packages for Python in order to have the Python include directory

提交回复
热议问题