Skip to content
Advertisement

Embedded Python3 raise an exception when importing a local module

I’m trying to embed a Pyhton3 program into a C++ one. After following several tutorials and blog posts I get the following code, which fails:

JavaScript

The result is the following:

JavaScript

So, importing sys works but importing my own module fails, while adding the path to my modules seemed to work.

Any idea ?

Advertisement

Answer

Replacing PyBytes_FromString by PyUnicode_DecodeFSDefault made the import work. I don’t understand why though.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement