Liveplotter error - QApplication was not created in the main() thread

I tried the command:

start_liveplotter(lambda: [odrv0.axis0.encoder.pos_estimate])

from within the interactive odrivetool instance as per the instructions here.

However, this throws the error:

Connected to ODrive 3653385F3030 as odrv0
In [1]: start_liveplotter(lambda: [odrv0.axis0.encoder.pos_estimate])
Out[1]: <fibre.utils.Event at 0x7fa37503e460>

/usr/local/lib/python3.8/dist-packages/odrive/ UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
  fig = plt.figure()
In [2]: WARNING: QApplication was not created in the main() thread.
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.8/", line 932, in _bootstrap_inner
  File "/usr/lib/python3.8/", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/dist-packages/odrive/", line 184, in plot_data
  File "/usr/local/lib/python3.8/dist-packages/matplotlib/backends/", line 408, in start_event_loop
    with _maybe_allow_interrupt(event_loop):
  File "/usr/lib/python3.8/", line 113, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.8/dist-packages/matplotlib/backends/", line 226, in _maybe_allow_interrupt
    old_wakeup_fd = signal.set_wakeup_fd(wsock.fileno())
ValueError: set_wakeup_fd only works in main thread

This seems to suggest that it is a matplotlib error that occurs when its functions are called from outside the main thread. Am I using this command incorrectly? Would really appreciate if someone could explain why I get this error since from the documentation it seems like this should just run?

I am using ODrive v3.6 - 56V; Firmware version: 0.5.4

Thank you.

Yeah, that’s normal. It should still open the plotter, and then throw weird errors when you close it.

Hi @Wetmelon, Thank you for your response.

When I attempt it, it does open the plotter window but its just a blank black window and I don’t see any live plot in it. On force quitting this window it kills the odrivetool interface along with the window. My Python version is 3.8. I am unsure if that is a factor.

1 Like

I had the same issue with the black plotter window. For me, the problem was that the graphics backend for matplotlib was QtAgg instead of KtAgg. See here for how to change that. Note that some of the methods they describe only apply to the current python instance and not every time python (or odrivetool) is launched. The matplotlibrc approach worked great for me as a permanent fix.

1 Like