Skip to content

F. Troubleshooting

Unai Alegre-Ibarra edited this page Sep 13, 2022 · 8 revisions

Troubleshooting

This wiki page is dedicated to common troubleshooting problems that you might encounter while installing and using brains-py.

1. ImportError: DLL load failed while importing win32api: The specified module could not be found.

The win32api library is needed in order to handle multi-threading on Windows machines. This is required in order to make sure that once a program starts sending data to the devices, using the driver, this can be stopped safely.

This error is caused by a difference in the installation between the library versions. Sometimes, pypiwin32 automatically installs the library pywin32 in an incorrect version. The problem can be solved by running the following command in your environment:

pip uninstall pypiwin32 pywin32

And then reinsall pywin32 with conda:

conda install pywin32

2. RuntimeError: main thread is not in main loop

By default matplotlib uses TK gui toolkit, when you're rendering an image without using the toolkit (i.e. into a file or a string), matplotlib still instantiates a window that doesn't get displayed, causing all kinds of problems. In order to avoid that, you should use an Agg backend. (from: Alex Volkov)

File "C:\Users\YOUR_USER\anaconda3\envs\bspy\lib\tkinter\__init__.py", line 4014, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <function Variable.__del__ at 0x000002DB856F0040>

Tcl_AsyncDelete: async handler deleted by the wrong thread

The solution is to change the default matplotlib engine to one that does not use a GUI:

import matplotlib
matplotlib.use('Agg')