AW: import python module from C++ code

Markus Schaber m.schaber at 3s-software.com
Mon Mar 7 02:01:17 EST 2011


Hi,

> von Arthur Mc Coy:

> Still need the answer to the question: " howto embed given python file
> (which contains python class and its members) into the c++ application
? "

There is no straight way of embedding a Python module into a c++
application.

You will have to embed the python interpreter, and command it to load
the module in question and execute the code you want.

> I have to pass the arguments from c++ to python and back so I need to
do
> conversions. They are ok. Fails PyImport_Import(my_module) call saying
"No
> module called mymodule". Then I need to create a mymodule based on
given
> python file (its name mymodule.py). Can it be achieved using SWIG ?

Did you configure the module search path properly?

Regards,
Markus



More information about the Python-list mailing list