Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8162

MicroPython • Re: Micropython embedded in a C program?

$
0
0
Many thanks to all users and comments!
@gmx : Good example, I had a possible solution in the Micropython
installation and never know of it, I try that!
@hippy: when You talk I have always to learn; we wait with patience
a "command line Python" to boost out Pico C programs

In one of various desperate tentatives I obtained a working executable,
but for my Raspberry Pi 400 develop machine, not for Pico:
in a new directory write this callpyth.c file

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include </usr/include/python3.11/Python.h>
#include </usr/include/python3.11/pythonrun.h>
int main() {
PyInitialize();
printf("\nWorks!\n");
PyRun_SimpleString("print(\"Hello, world!\")");
PyFinalize();
}

launching the compiler
$ gcc -o callpyth callpyth.c -lm -O3 -I/usr/include/python3.11/ -lpython3.11
I get an executable,
$ ./callpyth
output => Works!
=> Hello, world!

I try the example and I'll let you know.

Statistics: Posted by lorenzo_s — Sun Oct 12, 2025 8:37 pm



Viewing all articles
Browse latest Browse all 8162

Trending Articles