The issue comes from the Mbed framework. It seems that the latest version of Mbed framework does not support Python 3.12. What is more, Arm dropped support for the Mbed framework. So, no new features/bug fixes.
As the solution, you can try pyenv tool. I use it frequently to test PIO Core against different Python versions. You can install Python 3.9, and later use it to install PIO Core.
- Install
pyenv
andpython3.9
- Download the installer script Installer Script (Recommended) — PlatformIO latest documentation
- Remove
~/.platformio/penv
folder - Run
~/.pyenv/versions/3.9.XXXXXX/bin/python get-platformio.py
- Restart VSCode.
Did it help?