Debug fails (undefined error) for STM32F103RE

Error in Debug Console when I click run

undefinedError: Traceback (most recent call last):
  File "C:\Users\User\.platformio\penv\lib\site-packages\platformio\", line 109, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "C:\Users\User\.platformio\penv\lib\site-packages\click\", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\User\.platformio\penv\lib\site-packages\click\", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\User\.platformio\penv\lib\site-packages\platformio\commands\", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "C:\Users\User\.platformio\penv\lib\site-packages\click\", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\User\.platformio\penv\lib\site-packages\click\", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\User\.platformio\penv\lib\site-packages\click\", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\User\.platformio\penv\lib\site-packages\click\", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\User\.platformio\penv\lib\site-packages\platformio\commands\debug\", line 167, in cli
    from platformio.commands.debug.process.client import GDBClient, reactor
  File "C:\Users\User\.platformio\penv\lib\site-packages\platformio\commands\debug\process\", line 23, in <module>
    from twisted.internet import defer  # pylint: disable=import-error
  File "C:\Users\User\.platformio\packages\contrib-pysite\twisted\internet\", line 32, in <module>
    from twisted.logger import Logger
  File "C:\Users\User\.platformio\packages\contrib-pysite\twisted\logger\", line 102, in <module>
    from ._logger import Logger, _loggerFor
  File "C:\Users\User\.platformio\packages\contrib-pysite\twisted\logger\", line 274, in <module>
    _log = Logger()
  File "C:\Users\User\.platformio\packages\contrib-pysite\twisted\logger\", line 70, in __init__
    from ._global import globalLogPublisher
  File "C:\Users\User\.platformio\packages\contrib-pysite\twisted\logger\", line 16, in <module>
    from ._buffer import LimitedHistoryLogObserver
  File "C:\Users\User\.platformio\packages\contrib-pysite\twisted\logger\", line 11, in <module>
    from zope.interface import implementer
ModuleNotFoundError: No module named 'zope'


An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section

* Report this problem to the developers


ini file below:

platform = ststm32

board = genericSTM32F103RE

framework = arduino

lib_deps =



debug_tool = stlink

upload_protocol = stlink

I am using a SDLinkv2 SCLK and SWDIO GND and VCC, which works fine for uploading.

Any ideas?

Did some work on it and it looks like it was just python packages missing.

I did the following to fix it:

pip install zope.interface

pip install pywin32 

Did i miss an install step or is this a bug?


PlatformIO should install all needed Python packages upon its first installation.

Did you execute that in the global pip installation of your system or PlatformIO’s (in C:\Users\<user>\.platformio\penv)? PlatformIO runs in its own isolated python environment and thus shouldn’t rely on packages installed in the system’s pip.

Does this occurr after a fresh reinstall too? To do that,

  • remove the PlatformIO extension from VSCode and close VSCode
  • remove the folder C:\Users\User\.platformio\
  • re-open VSCode, reinstall PlatformIO, restart VSCode after installation has finished
  • retry building the project first, then debugging.