Do not set MPLCONFIGDIR to a temporary directory for mpl>=3

Author: anntzerCreated Jan 2, 2019Updated Jul 19, 2026
Labelsarea:hooks

In https://github.com/pyinstaller/pyinstaller/blob/master/PyInstaller/loader/rthooks/pyi_rth_mplconfig.py pyinstaller currently sets MPLCONFIGDIR to a temporary directory to work around the fact that Matplotlib's font cache used to write the path where matplotlib is installed to a cache file.

Since matplotlib 3.0 this is no longer the case (https://github.com/matplotlib/matplotlib/pull/10245), and the pyinstaller patch causes repeated rebuilds of the font cache, which slows down startup (https://github.com/matplotlib/matplotlib/issues/13071).

I would thus suggest making the setting of MPLCONFIGDIR to a temporary directory conditional on the version of Matplotlib (only if <3.0).


Additionally I see that there is another hook (pyi_rth_mpldata.py) setting the $MATPLOTLIBDATA environment variable as well; that environment variable may become unused if https://github.com/matplotlib/matplotlib/pull/11241 gets merged. Do you actually need it?