A few months ago, my project built and uploaded with no problem, however, I am no longer able to build, and I think this may be because I upgraded my Ubuntu system from 22.04 LTS (Jammy Jellyfish), which defaults to python 3.10, to 24.04 LTS (Noble Numbat), which defaults to python 3.12. I suspect this is an issue with the python version because I receive an error message when trying to build for mbed for importing a python library, imp, which is no longer supported with python 3.12, and the file from where the trace begins is in a folder labeled python3.12. It’s worth noting that I have no problem building and uploading with the Arduino environments in this project, so I think Platformio is installed correctly.
To resolve the issue I have tried uninstalling platformio in vscode, and deleting the .platformio folder, and then reinstalling platformio in vscode and rebuilding the .platformio folder when I re-open the project environment. I also downloaded python 3.11, and tried setting that as the interpreter for the file that attempts to import imp, but that just pushed the import error to attempts to import other files that are also not supported with python 3.12.
Please be understanding that this is my first-ever post, and let me know anything I should or shouldn’t include in the future :).
This import error happens when I attempt to build my project:
* Executing task: platformio run --environment vitalsMBED
Processing vitalsMBED (platform: nxplpc; board: lpc1768; framework: mbed)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nxplpc/lpc1768.html
PLATFORM: NXP LPC (10.0.0) > NXP mbed LPC1768
HARDWARE: LPC1768 96MHz, 64KB RAM, 512KB Flash
DEBUG: Current (cmsis-dap) On-board (cmsis-dap) External (blackmagic, jlink)
PACKAGES:
- framework-mbed @ 6.61700.231105 (6.17.0)
- toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
ModuleNotFoundError: No module named 'imp':
File "/home/torrey/.platformio/penv/lib/python3.12/site-packages/platformio/builder/main.py", line 173:
env.SConscript("$BUILD_SCRIPT")
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 612:
return _SConscript(self.fs, *files, **subst_kw)
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 279:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/torrey/.platformio/platforms/nxplpc/builder/main.py", line 116:
target_elf = env.BuildProgram()
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Util/envs.py", line 251:
return self.method(*nargs, **kwargs)
File "/home/torrey/.platformio/penv/lib/python3.12/site-packages/platformio/builder/tools/piobuild.py", line 61:
env.ProcessProgramDeps()
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Util/envs.py", line 251:
return self.method(*nargs, **kwargs)
File "/home/torrey/.platformio/penv/lib/python3.12/site-packages/platformio/builder/tools/piobuild.py", line 121:
env.BuildFrameworks(env.get("PIOFRAMEWORK"))
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Util/envs.py", line 251:
return self.method(*nargs, **kwargs)
File "/home/torrey/.platformio/penv/lib/python3.12/site-packages/platformio/builder/tools/piobuild.py", line 347:
SConscript(env.GetFrameworkScript(name), exports="env")
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 676:
return method(*args, **kw)
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 612:
return _SConscript(self.fs, *files, **subst_kw)
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 279:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/torrey/.platformio/platforms/nxplpc/builder/frameworks/mbed.py", line 35:
SConscript(
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 676:
return method(*args, **kw)
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 612:
return _SConscript(self.fs, *files, **subst_kw)
File "/home/torrey/.platformio/packages/tool-scons/scons-local-4.7.0/SCons/Script/SConscript.py", line 279:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/torrey/.platformio/packages/framework-mbed/platformio/platformio-build.py", line 37:
from pio_mbed_adapter import PlatformioMbedAdapter
File "/home/torrey/.platformio/packages/framework-mbed/platformio/pio_mbed_adapter.py", line 52:
from tools.build_api import prepare_toolchain, UPDATE_WHITELIST
File "/home/torrey/.platformio/packages/framework-mbed/tools/build_api.py", line 48:
from .libraries import Library
File "/home/torrey/.platformio/packages/framework-mbed/tools/libraries.py", line 25:
from tools.tests import TEST_MBED_LIB, DEFAULT_SUPPORT
File "/home/torrey/.platformio/packages/framework-mbed/tools/tests.py", line 18:
from past.builtins import cmp
File "/home/torrey/.platformio/packages/framework-mbed/platformio/package_deps/py3/past/builtins/__init__.py", line 54:
from past.builtins.misc import (apply, chr, cmp, execfile, intern, oct,
File "/home/torrey/.platformio/packages/framework-mbed/platformio/package_deps/py3/past/builtins/misc.py", line 45:
from imp import reload
==================================================================== [FAILED] Took 0.41 seconds ====================================================================
Environment Status Duration
------------- -------- ------------
vitalsMBED FAILED 00:00:00.413
============================================================== 1 failed, 0 succeeded in 00:00:00.413 ==============================================================
* The terminal process "platformio 'run', '--environment', 'vitalsMBED'" terminated with exit code: 1.
Here is the platformio.ini file. I am building this while in the vitalsMBED environment:
[env:mcu_node]
platform = nxplpc
board = lpc1768
framework = mbed
build_src_filter = +<mcu_node/> +<common/> +<arch/mbed.cpp>
monitor_port = /dev/ttyACM0
upload_port = /media/torrey/MBED
[env:vitalsMBED]
platform = nxplpc
board = lpc1768
framework = mbed
build_src_filter = +<vitals_node/mbedVitals.cpp> +<common/> +<arch/mbed.cpp>
monitor_port = /dev/ttyACM0
upload_port = /media/torrey/MBED
#lib_deps =
# mbed-hudakz/millis
[env:telemetry_node]
platform = atmelavr
board = uno
framework = arduino
build_src_filter = +<telemetry_node/> +<common/> +<arch/arduino.cpp>
lib_deps =
arkhipenko/TaskScheduler @ 3.7.0
sandeepmistry/CAN @ 0.3.1
monitor_port = /dev/ttyACM0
upload_port = /dev/ttyACM0
[env:vitals_node]
platform = atmelavr
board = uno
framework = arduino
build_src_filter = +<vitals_node/main.cpp> +<common/> +<arch/arduino.cpp> +<arch/arduino.hpp>
lib_deps =
arkhipenko/TaskScheduler @ 3.7.0
sandeepmistry/CAN @ 0.3.1
monitor_port = /dev/ttyACM0
upload_port = /dev/ttyACM0
[env:solovitals_node]
platform = atmelavr
board = uno
framework = arduino
build_src_filter = +<vitals_node/mainsolo.cpp> +<common/> +<arch/arduino.cpp> +<arch/arduino.hpp>
lib_deps =
arkhipenko/TaskScheduler @ 3.7.0
sandeepmistry/CAN @ 0.3.1
monitor_port = /dev/ttyACM0
upload_port = /dev/ttyACM0
[env:sensor_node]
platform = atmelavr
board = uno
framework = arduino
build_src_filter = +<vitals_node/sensor.cpp> +<common/> +<arch/arduino.cpp> +<arch/arduino.hpp>
lib_deps =
arkhipenko/TaskScheduler @ 3.7.0
sandeepmistry/CAN @ 0.3.1
monitor_port = /dev/ttyACM1
upload_port = /dev/ttyACM1
I have temporarily commented out my code so that the only code present is in the mbedVitals.cpp file.:
#include <mbed.h>
int main(){
}
VSCode highlights the #include <mbed.h> line claiming “include errors detected, cannot open source file mbed.h”. I also tried writing #include “mbed.h,” but that resulted in the same thing. So, here are the project IntelliSence Configurations:
/home/torrey/Documents/ProveMila-embedded/include
/home/torrey/Documents/ProveMila-embedded/src
/home/torrey/Documents/ProveMila-embedded/.pio/libdeps/solovitals_node/CAN/src
/home/torrey/.platformio/packages/framework-arduino-avr/libraries/SPI/src
/home/torrey/Documents/ProveMila-embedded/.pio/libdeps/solovitals_node/TaskScheduler/src
/home/torrey/.platformio/packages/framework-arduino-avr/cores/arduino
/home/torrey/.platformio/packages/framework-arduino-avr/variants/standard
/home/torrey/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src
/home/torrey/.platformio/packages/framework-arduino-avr/libraries/HID/src
/home/torrey/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src
/home/torrey/.platformio/packages/framework-arduino-avr/libraries/Wire/src