Pyinstaller not working together with matplotlib

Viewed 80

I'm writing a software and was using PyInstaller for packaging/distribution. However, we began to use matplotlib and now PyInstaller doesn't work anymore. I wrote a small MCVE so that you can see what's happening. I'm using Python 3.9.1, PyInstaler's development version, and Matplotlib 3.5.1 (updated just now) on Linux (although my software has to work on Windows as well).

Here is the MCVE:

import matplotlib.pyplot as plt

x = range(10)
y = [z ** 2 for z in x]
plt.plot(x, y)
plt.show()

I saved this as main.py and ran the following:

(base) $ pyinstaller main.py

This produces an error, with the following relevant part:

File "/home/helitonmrf/miniconda3/envs/QSARModelingGUI/lib/python3.9/site-packages/PyInstaller/depend/imphook.py", line 364, in _load_hook_module
    raise ImportErrorWhenRunningHook(self.hook_module_name, self.hook_filename)
PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_IPython required by hook for module /home/helitonmrf/miniconda3/envs/QSARModelingGUI/lib/python3.9/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-IPython.py. Please check whether module __PyInstaller_hooks_0_IPython actually exists and whether the hook is compatible with your version of /home/helitonmrf/miniconda3/envs/QSARModelingGUI/lib/python3.9/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-IPython.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller.

The full log is here.


I first tried to update pyinstaller and matplotlib (and it changed the error), and also tried to add matplotlib to hiddenimports, but nothing changed.

0 Answers
Related