Python error on vscode, cannot start debug session

Hello, just started with platformIO, i was trying to setup my nucleo L476R board, all went fine except for debugging in vscode.

I can debug via gdb, so board and debugger itself are ok, im using:

pio debug --interface=gdb -x .pioinit

Vscode debugging its not working, im using the PIO DEBUG profile that is autogenerated with the platform configuration, builds, uploads then stops, this log appears on debug console:

undefinedRuntimeError: Traceback (most recent call last):
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/platformio/main.py”, line 103, in main
cli() # pylint: disable=no-value-for-parameter
~~~^^
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/click/core.py”, line 1157, in call
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/click/core.py”, line 1078, in main
rv = self.invoke(ctx)
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/platformio/cli.py”, line 85, in invoke
return super().invoke(ctx)
~~~~~~~~~~~~~~^^^^^
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/click/core.py”, line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/click/core.py”, line 783, in invoke
return __callback(*args, **kwargs)
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/click/decorators.py”, line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/platformio/debug/cli.py”, line 109, in cli
_run(os.getcwd(), debug_config, client_extra_args)
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/fran/.platformio/penv/lib64/python3.14/site-packages/platformio/debug/cli.py”, line 170, in _run
loop = asyncio.ProactorEventLoop() if IS_WINDOWS else asyncio.get_event_loop()
~~~~~~~~~~~~~~~~~~~~~~^^
File “/usr/lib64/python3.14/asyncio/events.py”, line 715, in get_event_loop
raise RuntimeError(‘There is no current event loop in thread %r.’
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread ‘MainThread’.

I have tried to updae python, reinstall platformIO, updated vscode and my system is up to date. (Linux Fedora 43)

I was not able to debug with an arduino board too, so i think its something python related, any ideas on how to solve?

Thanks.

I’ve never seen that before. Also very suspucious that PlatformIO’s cli.py is using the asyncio library from /usr/lib64/python3.14/ – in my understanding those should be seperate if PlatformIO was installed normally (not globally).

Can you

?

Thanks for the help.

Did all the steps but nothing changed, also there another person having same problem on the github issues page (link below).

CC @ivankravets just for completeness, may have to do with 3.14 python interpreter?

Well meanwhile im using a workarround:

  • removed all, extension and config folder (~./platformio)
  • switched another python version i had installed on my system (3.10):
    sudo alternatives --config python3
  • fresh install vscode platformio extension

Now i can debug. but it is somehow attached to system’s python version, if i switch back then platformio re-installs itselft and stops working.

1 Like

Support for Python 3.14 was added to the recent development branch. Could you try pio upgrade --dev. Does it work now?

Tried de dev branch, still not working, same python messages. Well if you are not able to replicate maybe its something messed on my system, but i though platformio is using a venv so how come the system python version has nothing to do with it…

Exactly the same message? Because

should have modified exactly that place, calling into loop = asyncio.new_event_loop() as a fallback. It should not crash at the previous

Will check tonight on a clean computer.

Edit: seems fine on fresh computer. Probably a python version mess in my fedora. But this should be managed in the penv and not mess with the system version.

Thanks for the help!