If your pyinstaller is lower than 4.0, when you attempt to package matplotlib,
you will occurred an error about mpl-data:
/usr/local/lib/python3.6/dist-packages/PyInstaller/loader/pyimod03_importers.py:623: MatplotlibDeprecationWarning: Matplotlib installs where the data is not in the mpl-data subdirectory of the package are deprecated since 3.2 and support for them will be removed two minor releases later.
In --onefile mode, based on this commit by a PyInstaller contributor, which references https://github.com/pyinstaller/pyinstaller/issues/5004, you can just modify PyInstaller\hooks\hook-matplotlib.py so that it has:
datas = [
(mpl_data_dir, "matplotlib/mpl-data"),
]
instead of
datas = [
(mpl_data_dir, "mpl-data"),
]