I am trying to create an application for windows, and I have narrowed my issue down to something about matplotlib is not jiving with pyinstaller. The most simple script I have created that doesn't work is:
import matplotlib.pyplot as plt
plt.plot([1])
plt.show()
This script works like expected when running from python directly, and Pyinstaller creates an executable with no errors using the command:
pyinstaller --onefile --hidden-import=pkg_resources.py2_warn plot.py
However, when I try to run the executable, windows pops up an error:
I am using: Python 3.7.7 MatPlotLib 3.0.3 setuptools 46.4.0 pyinstaller 3.6
Below is the output from pyinstaller:
54 INFO: PyInstaller: 3.6
55 INFO: Python: 3.7.7 (conda)
56 INFO: Platform: Windows-10-10.0.17763-SP0
57 INFO: wrote **path removed for security reasons**\plot.spec
58 INFO: UPX is not available.
60 INFO: Extending PYTHONPATH with paths
['**path removed for security reasons**',
'**path removed for security reasons**']
60 INFO: checking Analysis
60 INFO: Building Analysis because Analysis-00.toc is non existent
60 INFO: Initializing module dependency graph...
64 INFO: Caching module graph hooks...
70 INFO: Analyzing base_library.zip ...
1726 INFO: Processing pre-find module path hook distutils
1726 INFO: distutils: retargeting to non-venv dir '**path removed for security reasons**'
2784 INFO: Caching module dependency graph...
2867 INFO: running Analysis Analysis-00.toc
2881 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by **path removed for security reasons**
3110 INFO: Analyzing **path removed for security reasons**
4950 INFO: Processing pre-find module path hook site
4951 INFO: site: retargeting to fake-dir '**path removed for security reasons**'
7359 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
10269 INFO: Processing pre-safe import module hook six.moves
14027 INFO: Processing pre-safe import module hook urllib3.packages.six.moves
28434 INFO: Analyzing hidden import 'pkg_resources.py2_warn'
28435 INFO: Processing module hooks...
28435 INFO: Loading module hook "hook-babel.py"...
28548 INFO: Loading module hook "hook-certifi.py"...
28549 INFO: Loading module hook "hook-cryptography.py"...
28810 INFO: Loading module hook "hook-distutils.py"...
28811 INFO: Loading module hook "hook-docutils.py"...
31881 INFO: Loading module hook "hook-encodings.py"...
31971 INFO: Loading module hook "hook-importlib_metadata.py"...
31974 INFO: Loading module hook "hook-IPython.py"...
32298 INFO: Excluding import 'PySide'
32302 INFO: Removing import of PySide from module IPython.external.qt_loaders
32303 INFO: Excluding import 'gtk'
32307 INFO: Excluding import 'PyQt4'
32310 INFO: Removing import of PyQt4 from module IPython.external.qt_loaders
32311 INFO: Excluding import 'PyQt5'
32315 INFO: Removing import of PyQt5.QtWidgets from module IPython.external.qt_loaders
32316 INFO: Removing import of PyQt5.QtGui from module IPython.external.qt_loaders
32316 INFO: Removing import of PyQt5 from module IPython.external.qt_loaders
32316 INFO: Removing import of PyQt5.QtCore from module IPython.external.qt_loaders
32316 INFO: Removing import of PyQt5.QtSvg from module IPython.external.qt_loaders
32318 INFO: Excluding import 'tkinter'
32321 INFO: Removing import of tkinter from module IPython.lib.clipboard
32322 INFO: Excluding import 'matplotlib'
32325 INFO: Removing import of matplotlib.pyplot from module IPython.core.pylabtools
32325 INFO: Removing import of matplotlib.figure from module IPython.core.pylabtools
32326 INFO: Removing import of matplotlib.backend_bases from module IPython.core.pylabtools
32326 INFO: Removing import of matplotlib._pylab_helpers from module IPython.core.pylabtools
32327 INFO: Removing import of matplotlib from module IPython.core.pylabtools
32328 INFO: Loading module hook "hook-jedi.py"...
32536 INFO: Loading module hook "hook-jinja2.py"...
32549 INFO: Loading module hook "hook-jsonschema.py"...
32553 INFO: Loading module hook "hook-lib2to3.py"...
32556 INFO: Loading module hook "hook-matplotlib.backends.py"...
33292 INFO: Matplotlib backend "GTK3Agg": ignored
The GTK3 backends require PyGObject
33687 INFO: Matplotlib backend "GTK3Cairo": ignored
The GTK3 backends require PyGObject
34087 INFO: Matplotlib backend "MacOSX": ignored
cannot import name '_macosx' from 'matplotlib.backends' (**path removed for security reasons**)
34848 INFO: Matplotlib backend "nbAgg": added
35342 INFO: Matplotlib backend "Qt4Agg": added
35914 INFO: Matplotlib backend "Qt4Cairo": added
36410 INFO: Matplotlib backend "Qt5Agg": added
36928 INFO: Matplotlib backend "Qt5Cairo": added
37372 INFO: Matplotlib backend "TkAgg": added
37795 INFO: Matplotlib backend "TkCairo": added
38239 INFO: Matplotlib backend "WebAgg": added
38682 INFO: Matplotlib backend "WX": added
39139 INFO: Matplotlib backend "WXAgg": added
39581 INFO: Matplotlib backend "WXCairo": added
39889 INFO: Matplotlib backend "agg": added
40190 INFO: Matplotlib backend "cairo": added
40633 INFO: Matplotlib backend "pdf": added
41119 INFO: Matplotlib backend "pgf": added
41449 INFO: Matplotlib backend "ps": added
41787 INFO: Matplotlib backend "svg": added
42200 INFO: Matplotlib backend "template": added
42726 INFO: Loading module hook "hook-matplotlib.py"...
42998 INFO: Loading module hook "hook-nacl.py"...
43000 INFO: Loading module hook "hook-nbconvert.py"...
43019 INFO: Loading module hook "hook-nbformat.py"...
43027 INFO: Loading module hook "hook-numpy.core.py"...
43105 INFO: MKL libraries found when importing numpy. Adding MKL to binaries
43110 INFO: Loading module hook "hook-numpy.py"...
43111 INFO: Loading module hook "hook-PIL.Image.py"...
43483 INFO: Loading module hook "hook-PIL.py"...
43486 INFO: Excluding import 'PySide'
43489 INFO: Excluding import 'PyQt4'
43491 INFO: Import to be excluded not found: 'FixTk'
43491 INFO: Excluding import 'PyQt5'
43494 INFO: Removing import of PyQt5.QtCore from module PIL.ImageQt
43494 INFO: Removing import of PyQt5.QtGui from module PIL.ImageQt
43496 INFO: Excluding import 'tkinter'
43498 INFO: Removing import of tkinter from module PIL.ImageTk
43499 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
43501 INFO: Import to be excluded not found: 'FixTk'
43501 INFO: Excluding import 'tkinter'
43505 INFO: Loading module hook "hook-pkg_resources.py"...
44029 INFO: Processing pre-safe import module hook win32com
44262 INFO: Excluding import '__main__'
44265 INFO: Removing import of __main__ from module pkg_resources
44266 INFO: Loading module hook "hook-pycparser.py"...
44266 INFO: Loading module hook "hook-pydoc.py"...
44266 INFO: Loading module hook "hook-pygments.py"...
45699 INFO: Loading module hook "hook-PyQt5.py"...
46033 WARNING: Hidden import "PyQt5.sip" not found!
46033 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
46095 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
46239 INFO: Loading module hook "hook-PyQt5.QtSvg.py"...
46639 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
46771 INFO: Loading module hook "hook-pythoncom.py"...
47193 INFO: Loading module hook "hook-pytz.py"...
47287 INFO: Loading module hook "hook-pywintypes.py"...
47699 INFO: Loading module hook "hook-setuptools.py"...
48378 INFO: Loading module hook "hook-sphinx.py"...
52440 INFO: Loading module hook "hook-sqlite3.py"...
52534 INFO: Loading module hook "hook-sysconfig.py"...
52535 INFO: Loading module hook "hook-win32com.py"...
53006 INFO: Loading module hook "hook-xml.dom.domreg.py"...
53006 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
53007 INFO: Loading module hook "hook-xml.py"...
53007 INFO: Loading module hook "hook-zmq.py"...
55179 INFO: Loading module hook "hook-_tkinter.py"...
55347 INFO: checking Tree
55347 INFO: Building Tree because Tree-00.toc is non existent
55348 INFO: Building Tree Tree-00.toc
55422 INFO: checking Tree
55422 INFO: Building Tree because Tree-01.toc is non existent
55422 INFO: Building Tree Tree-01.toc
55434 INFO: Loading module hook "hook-gevent.py"...
55880 INFO: Determining a mapping of distributions to packages...
81899 WARNING: Unable to find package for requirement zope.interface from package gevent.
81899 WARNING: Unable to find package for requirement zope.event from package gevent.
81900 WARNING: Unable to find package for requirement greenlet from package gevent.
81900 INFO: Packages required by gevent:
['setuptools', 'cffi']
83012 INFO: Looking for ctypes DLLs
83121 INFO: Analyzing run-time hooks ...
83134 INFO: Including run-time hook 'pyi_rth_pkgres.py'
83136 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
83137 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
83139 INFO: Including run-time hook 'pyi_rth_traitlets.py'
83140 INFO: Including run-time hook 'pyi_rth__tkinter.py'
83141 INFO: Including run-time hook 'pyi_rth_certifi.py'
83142 INFO: Including run-time hook 'pyi_rth_pyqt5.py'
83143 INFO: Including run-time hook 'pyi_rth_mplconfig.py'
83144 INFO: Including run-time hook 'pyi_rth_mpldata.py'
83177 INFO: Looking for dynamic libraries
83234 WARNING: lib not found: pgf90rtl.dll dependency of **path removed for security reasons**\mkl_pgi_thread.dll
83238 WARNING: lib not found: pgc14.dll dependency of **path removed for security reasons**\mkl_pgi_thread.dll
83239 WARNING: lib not found: pgf90.dll dependency of **path removed for security reasons**\mkl_pgi_thread.dll
83243 WARNING: lib not found: mpich2mpi.dll dependency of **path removed for security reasons**\mkl_blacs_mpich2_ilp64.dll
83539 WARNING: lib not found: mpich2mpi.dll dependency of **path removed for security reasons**\mkl_blacs_mpich2_lp64.dll
83557 WARNING: lib not found: impi.dll dependency of **path removed for security reasons**\mkl_blacs_intelmpi_ilp64.dll
83818 WARNING: lib not found: impi.dll dependency of **path removed for security reasons**\mkl_blacs_intelmpi_lp64.dll
85161 INFO: Looking for eggs
85161 INFO: Using Python library **path removed for security reasons**\python37.dll
85162 INFO: Found binding redirects:
[]
85183 INFO: Warnings written to **path removed for security reasons**\warn-plot.txt
85518 INFO: Graph cross-reference written to **path removed for security reasons**\xref-plot.html
85737 INFO: checking PYZ
85738 INFO: Building PYZ because PYZ-00.toc is non existent
85738 INFO: Building PYZ (ZlibArchive) **path removed for security reasons**\PYZ-00.pyz
89239 INFO: Building PYZ (ZlibArchive) **path removed for security reasons**\PYZ-00.pyz completed successfully.
89317 INFO: checking PKG
89317 INFO: Building PKG because PKG-00.toc is non existent
89318 INFO: Building PKG (CArchive) PKG-00.pkg
173383 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
173522 INFO: Bootloader **path removed for security reasons**\Windows-64bit\run.exe
173523 INFO: checking EXE
173524 INFO: Building EXE because EXE-00.toc is non existent
173524 INFO: Building EXE from EXE-00.toc
173525 INFO: Appending archive to EXE **path removed for security reasons**\dist\plot.exe
173714 INFO: Building EXE from EXE-00.toc completed successfully.
