0

My .exe generated is failed to execute with a matplotlib program.

54 INFO: PyInstaller: 4.0 54 INFO: Python: 3.7.8rc1 57 INFO: Platform: Windows-10-10.0.18362-SP0 58 INFO: wrote C:\Users\vnareshk\AppData\Local\Programs\Python\Python37\Scripts\Chart.spec 59 INFO: UPX is not available. 61 INFO: Extending PYTHONPATH with paths ['c:\Users\vnareshk\Desktop\UPH\pythonProject', 'C:\Users\vnareshk\AppData\Local\Programs\Python\Python37\Scripts'] 69 INFO: checking Analysis 69 INFO: Building Analysis because Analysis-00.toc is non existent 70 INFO: Initializing module dependency graph... 73 INFO: Caching module graph hooks... 86 INFO: Analyzing base_library.zip ... 1622 INFO: Processing pre-find module path hook distutils from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\pre_find_module_path\hook-distutils.py'. 1624 INFO: distutils: retargeting to non-venv dir 'c:\users\vnareshk\appdata\local\programs\python\python37\lib' 2624 INFO: Caching module dependency graph... 2711 INFO: running Analysis Analysis-00.toc 2726 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable required by c:\users\vnareshk\appdata\local\programs\python\python37\python.exe 2785 INFO: Analyzing c:\Users\vnareshk\Desktop\UPH\pythonProject\Chart. 3339 INFO: Processing pre-find module path hook site from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\pre_find_module_path\hook-site.py'. 3340 INFO: site: retargeting to fake-dir 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\fake-modules' 6847 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-setuptools.extern.six.moves.py'. 10194 INFO: Processing pre-safe import module hook six.moves from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-six.moves.py'. 12483 INFO: Processing module hooks... 12483 INFO: Loading module hook 'hook-certifi.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks'... 12491 INFO: Loading module hook 'hook-pycparser.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks'... 12492 INFO: Loading module hook 'hook-distutils.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 12493 INFO: Loading module hook 'hook-encodings.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 12583 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 12630 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 13120 INFO: Matplotlib backend "GTK3Agg": ignored backend Gtk3Agg requires cairo 13381 INFO: Matplotlib backend "GTK3Cairo": ignored cairo backend requires that pycairo>=1.11.0 or cairocffiis installed 13629 INFO: Matplotlib backend "MacOSX": ignored cannot import name 'macosx' from 'matplotlib.backends' (c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\matplotlib\backends_init.py) 13873 INFO: Matplotlib backend "nbAgg": ignored No module named 'IPython' 14206 INFO: Matplotlib backend "Qt4Agg": ignored Failed to import any qt binding 14456 INFO: Matplotlib backend "Qt4Cairo": ignored cairo backend requires that pycairo>=1.11.0 or cairocffiis installed 14776 INFO: Matplotlib backend "Qt5Agg": ignored Failed to import any qt binding 15020 INFO: Matplotlib backend "Qt5Cairo": ignored cairo backend requires that pycairo>=1.11.0 or cairocffiis installed 15467 INFO: Matplotlib backend "TkAgg": added 15902 INFO: Matplotlib backend "TkCairo": ignored cairo backend requires that pycairo>=1.11.0 or cairocffiis installed 16314 INFO: Matplotlib backend "WebAgg": added 16733 INFO: Matplotlib backend "WX": ignored No module named 'wx' 16975 INFO: Matplotlib backend "WXAgg": ignored No module named 'wx' 17218 INFO: Matplotlib backend "WXCairo": ignored No module named 'wx' 17529 INFO: Matplotlib backend "agg": added 17772 INFO: Matplotlib backend "cairo": ignored cairo backend requires that pycairo>=1.11.0 or cairocffiis installed 18185 INFO: Matplotlib backend "pdf": added 18604 INFO:
Matplotlib backend "pgf": added 18911 INFO: Matplotlib backend "ps": added 19226 INFO: Matplotlib backend "svg": added 19649 INFO:
Matplotlib backend "template": added 19858 INFO: Loading module hook 'hook-matplotlib.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 20112 INFO: Loading module hook 'hook-numpy.core.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 20180 INFO: Loading module hook 'hook-numpy.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 20181 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 20480 INFO: Loading module hook 'hook-PIL.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 20482 INFO: Import to be excluded not found: 'PyQt4' 20482 INFO: Import to be excluded not found: 'FixTk' 20483 INFO: Excluding import 'PyQt5' 20484 INFO: Removing import of PyQt5 from module PIL.ImageQt 20485 INFO: Excluding import 'tkinter' 20487 INFO: Removing import of tkinter from module PIL.ImageTk 20487 INFO: Import to be excluded not found: 'PySide' 20487 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 20489 INFO: Excluding import 'tkinter' 20490 INFO: Import to be excluded not found: 'FixTk' 20490 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 20911 INFO: Processing pre-safe import module hook win32com from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\pre_safe_import_module\hook-win32com.py'. 20980 WARNING: Hidden import "pkg_resources.markers" not found! 20981 INFO: Excluding import 'main' 20983 INFO: Removing import of main from module pkg_resources 20984 INFO: Loading module hook 'hook-setuptools.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 21497 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 21498 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 21499 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 21500 INFO: Loading module hook 'hook-xml.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 21500 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks'... 21674 INFO: checking Tree 21674 INFO: Building Tree because Tree-00.toc is non existent 21676 INFO: Building Tree Tree-00.toc 21734 INFO: checking Tree 21734 INFO: Building Tree because Tree-01.toc is non existent 21736 INFO: Building Tree Tree-01.toc 21746 INFO: Loading module hook 'hook-pythoncom.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks'... 22055 INFO: Loading module hook 'hook-pywintypes.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks'... 22359 INFO: Loading module hook 'hook-win32com.py' from 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks'... 22704 INFO: Looking for ctypes DLLs 22758 INFO: Analyzing run-time hooks ... 22764 INFO: Including run-time hook 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py' 22767 INFO: Including run-time hook 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth__tkinter.py' 22768 INFO: Including run-time hook 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py' 22770 INFO: Including run-time hook 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_win32comgenpy.py' 22772 INFO: Including run-time hook 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_mplconfig.py' 22772 INFO: Including run-time hook 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_mpldata.py' 22773 INFO: Including run-time hook 'c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\rthooks\pyi_rth_certifi.py' 22786 INFO: Looking for dynamic libraries 23468 INFO: Looking for eggs 23469 INFO: Using Python library c:\users\vnareshk\appdata\local\programs\python\python37\python37.dll 23471 INFO: Found binding redirects: [] 23480 INFO: Warnings written to C:\Users\vnareshk\AppData\Local\Programs\Python\Python37\Scripts\build\Chart\warn-Chart.txt 23603 INFO: Graph cross-reference written to C:\Users\vnareshk\AppData\Local\Programs\Python\Python37\Scripts\build\Chart\xref-Chart.html 23664 INFO: checking PYZ 23665 INFO: Building PYZ because PYZ-00.toc is non existent 23667 INFO: Building PYZ (ZlibArchive) C:\Users\vnareshk\AppData\Local\Programs\Python\Python37\Scripts\build\Chart\PYZ-00.pyz 25350 INFO: Building PYZ (ZlibArchive) C:\Users\vnareshk\AppData\Local\Programs\Python\Python37\Scripts\build\Chart\PYZ-00.pyz completed successfully. 25386 INFO: checking PKG 25386 INFO: Building PKG because PKG-00.toc is non existent 25388 INFO: Building PKG (CArchive) PKG-00.pkg 33608 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully. 33643 INFO: Bootloader c:\users\vnareshk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe 33643 INFO: checking EXE 33647 INFO: Building EXE because EXE-00.toc is non existent 33648 INFO: Building EXE from EXE-00.toc 33648 INFO: Appending archive to EXE C:\Users\vnareshk\AppData\Local\Programs\Python\Python37\Scripts\dist\Chart.exe 33674 INFO: Building EXE from EXE-00.toc completed successfully.

Here is my code:

import PySimpleGUI as sg
import matplotlib.pyplot as plt
def draw_plot():
    plt.plot([0.1, 0.2, 0.5, 0.7,0.2])
    plt.show(block=False)
layout = [[sg.Button('Plot'), sg.Cancel(), sg.Button('Popup')]]
window = sg.Window('Have some Matplotlib....', layout)
while True:
    event, values = window.read()
    if event in (sg.WIN_CLOSED, 'Cancel'):
        break
    elif event == 'Plot':
        draw_plot()
    elif event == 'Popup':
        sg.popup('Yes, your application is still running')
window.close()
jairoar
  • 217
  • 1
  • 9
  • 1
    Put `console = True` in your myspec file, then execute your .exe and check what is the error in the console. – jairoar Sep 18 '20 at 15:50
  • _"Building EXE from EXE-00.toc completed successfully."_ This is what the code says, what error did you experience, did you try running the file in the `dist` folder? Include the error codes too – Delrius Euphoria Sep 18 '20 at 16:05
  • When I run the exe file, I get "Fatal error, failed to execute the script chart". – naresh teradyne Sep 18 '20 at 16:10

1 Answers1

0

I've encountered problems like this. Here's what I suggest:

First, compile your code like this

pyinstaller -F your_script.py

This will compile into an .exe and leave a debug window open in the background that will display necessary information for next steps.

Next, locate and run your .exe. Before the script fails you will see on the debug window the error that's causing the crash. The biggest culprit I've seen lately is the pkg_resources.py2_warn import error.

Last, add an import statement at the top of your code that forces the import of whatever is causing pyinstaller to build a bad .exe. For instance, with the pkg_resources error I was having I ended up adding:

import pkg_resources.py2_warn

And now it compiles properly and the executable works.

MacItaly
  • 345
  • 4
  • 16