Where's the subprocess module for Thonny?

116 views
Skip to first unread message

Jonathan Titus

unread,
Jul 29, 2024, 12:06:40 AM7/29/24
to thonny
I'd like to use a subprocess in a Python program that runs on a Raspberry Pi Pico board.  When I try a simple test example:

in:  main_program.py

import subprocess
def run_script():
    print("Running the script...")
    subprocess.run(["python", "other_script.py"])
    print("Execution completed.")
   
if __name__ == "__main__":
    run_script()
    print("Back in the main program.")


in:  other_script.py: 

print("Hello from the other script.")

I get this error message from Thonny:

MPY: soft reboot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'subprocess'


Any suggestions?  Thank you.  --Jon

Paul Naish

unread,
Jul 29, 2024, 8:09:15 AM7/29/24
to thonny
Sub process is only applicable when Python is running on an OS. Pico is a microcontroller running firmware. 

The closest analogy would be to run something on the 2nd core of the PICO CPU. 

Reply all
Reply to author
Forward
0 new messages