Can I run a python script while using C?

Hello, I made some stuff with C. Now, I need some API's that are only available for Python or JS, so I'd require to run a python script in my current program. Is this possible, and if yes, how?


I need some API's that are only available for Python or JS

what's your Arduino ? does it have an OS, multi-threading support, a Python environment etc ?

(what are those API?)

Which "C" C#, C, C++?
C are all compiled programs while python is a interpreter-language. As long as you don't run them on a full blown operating-system like Linux, Windows or Raspbian you have the choice between installing a python-interpreter or your compiled program but not both.

You are working on an informatic project and what is most needed on a informatic project is information. So what are the devices you are using? What are the devices doing?

best regards Stefan

In regards to the current spate of Arduino IDE compatible MCU's, running Cwhatever and Python on the same machine is not an option.

An RPi might be more suited

1 Like

if it’s Cxx running on the Arduino, and your ‘other’ program is on something else.
You need to write the code to support the API on the Arduino in Cxx.

The other machine will write / read via whatever interface you choose to call the API in the Arduino.

The python code exists elsewhere.

In theory it might be possible to run Python and C code in the RP2040 processor as it has two cores. So you could have C running in one and a Python interpreter on the other.
I don’t think any one has done that yet and it will be quite a challenge but it is a possibility.

According to Arduino website you can run both codes on Portenta H7

For example, is possible to execute Arduino compiled code along with MicroPython one, and have both cores to communicate with one another.

1 Like

not on a current version of thonny. it wants micropython on the pico

worst idea ever. it all comes down to support. teensy has the best specs and worst support. no decent resolution tfts. they will go under soon probably. $100 for portenta to do what a $10 pi zero can do... hmmm i wonder which will still be made in 4 years. i wonder which has had more progress towards real world usage. you can run linux and pygame and python and micro python vs c and micropython. the lowest end of both worlds is kinda meh atleast shoot for c++ or python

" 'needing' an API" make no sense at all.
API's are defined. This way toooo less information about what your situation is:

There is your µC and some other device or a website or any else internetservice.

So what is it? I estimate you don't know the details of it.
So at least can you please post the names of:

  • your C-language-dialect
  • the development-system you used to program the "some stuff in C"
  • the thing that has the python/JS-API

There is a good chance that the solution to make the "two things" work together is pretty different than you think.
best regards Stefan

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.