Python Forum
embed python script in C programm - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: embed python script in C programm (/thread-39397.html)



embed python script in C programm - gucio321 - Feb-11-2023

Hi everyone!
I'm working on a project written in GO and some time ago our team was made to use a python module (as it was the only available). Go uses a technology called CGO to embed C code. (these information probably does not matter in the real topic, but I wanted to share some context)

I reached two problems:
#1 C and linker flags:
on linux, there is a python3-config script that finds out necessary flags to be passed to ld/gcc over that, there is a pkg-config command that does the work even easier. Generally there is no problems on linux.
Anyway, our application needs to be shipped mostly for windows enviroument, and here is the real problemm: how to compile our app on windows? How to find appropiate linker flags to fix "Python.h" not such file or directory error?
#2 how to embed python3 iterpreter?
I managed to cross-compile my application on linux for windows via mingw, however now I'm getting the following error on windows machine trying to run my .exe:
[Image: image.png]
This windows machine does not have python3 installed so I suppose that my exe does not contain it and searches system variables for that. Is there any way to embed python compiler in my exec?

Feel free to ask me about any details, I forgot to mention about.
Thank you in advance for all your help!
M. Sz.