I have some modules on a Raspberry Pi pico in one directory.
From the main module, I want to run the script from another module.I have tried to use the code subproces.run(python, “module name”), but that doesn’t work.
This is the code from the module I called ‘update rtc module’:
from machine import I2C, Pin
from ds3231_gen import *
import time
If the module is called update rtc module.py it might not work on some versions (at least afaik), because of the whitespace in the name / in the command. I would either
a) Rename the file to something like update_rtc_module.py
b) Use the command python “update_rtc_module.py” instead, meaning you’ll do subprocess.run(f”{python_executable} ‘{filename}’”.split())
I would advise you to just rename files if possible. It makes it a lot easier for a lot of tools to be able to use the file, especially in the terminal. Needing to wrap file/path names in "” is something that I sadly have to do in some cases, and it makes me go mad.
Thank you all for your replies. The Import statement works fine for me, but the other answers were also helpful. Now I understand the subprocess better.
Thanks again.
Lo