'Python app to one file .exe, after compiling app won't run

Hello once again editing, My major issue was resolved, however, my up running to new issues when compiled, probably deserves a new post. I'm trying to research this issue. So far I found up that pyinstaller does not do jinja2. However, I can see in their update from 2018 that pyinstaller can do that now. I'll keep on researching, thanks for the help so far.

Edit: Hello, I found a cause of my error. I wasn't pulling Ico file included in my app. But now I'm getting new problem, my jinja2 isn't getting into the app.

I did try: --hiddenimport "jinja2" I've also tried: --additional-hooks-dir "C:/Users/bk/Desktop/app/venv/Lib/site-packages/jinja2"

Executing: pyinstaller --noconfirm --onefile --noconsole --icon C:/Users/bk/Desktop/Source H/logo.ico C:/Users/bk/Desktop/Source H/app.py --distpath C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\application --workpath C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\build --specpath C:\Users\bk\AppData\Local\Temp\tmphyctj9hl

88139 INFO: PyInstaller: 3.6
88142 INFO: Python: 3.7.4
88147 INFO: Platform: Windows-10-10.0.17763-SP0
88154 INFO: wrote C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\app.spec
88161 INFO: UPX is not available.
88171 INFO: Extending PYTHONPATH with paths
['C:\\Users\\bk\\Desktop\\Source H',
 'C:\\Users\\bk\\AppData\\Local\\Temp\\tmphyctj9hl']
88175 INFO: checking Analysis
88178 INFO: Building Analysis because Analysis-00.toc is non existent
88186 INFO: Initializing module dependency graph...
88192 INFO: Caching module graph hooks...
88205 INFO: Analyzing base_library.zip ...
91478 INFO: Caching module dependency graph...
91608 INFO: running Analysis Analysis-00.toc
91644 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\bk\appdata\local\programs\python\python37\python.exe
91853 INFO: Analyzing C:\Users\bk\Desktop\Source H\app.py
92968 INFO: Processing pre-find module path hook   distutils
92984 INFO: distutils: retargeting to non-venv dir 'c:\\users\\bk\\appdata\\local\\programs\\python\\python37\\lib'
99328 INFO: Processing pre-find module path hook   site
99348 INFO: site: retargeting to fake-dir 'c:\\users\\bk\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\fake-modules'
101088 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
109239 INFO: Processing pre-safe import module hook   six.moves
116423 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
118005 INFO: Processing module hooks...
118009 INFO: Loading module hook "hook-certifi.py"...
118027 INFO: Loading module hook "hook-distutils.py"...
118050 INFO: Loading module hook "hook-encodings.py"...
118205 INFO: Loading module hook "hook-gevent.py"...
118943 INFO: Determining a mapping of distributions to packages...
123570 WARNING: Unable to find package for requirement greenlet from package gevent.
123573 INFO: Packages required by gevent:
['cffi']
126368 INFO: Loading module hook "hook-jinja2.py"...
126422 INFO: Loading module hook "hook-lib2to3.py"...
126448 INFO: Loading module hook "hook-lxml.etree.py"...
126466 INFO: Loading module hook "hook-numpy.core.py"...
126648 INFO: Loading module hook "hook-numpy.py"...
126665 INFO: Loading module hook "hook-pandas.py"...
128033 INFO: Loading module hook "hook-PIL.Image.py"...
128823 INFO: Loading module hook "hook-PIL.py"...
128841 INFO: Excluding import 'tkinter'
128850 INFO:   Removing import of tkinter from module PIL.ImageTk
128853 INFO: Excluding import 'PyQt5'
128858 INFO:   Removing import of PyQt5 from module PIL.ImageQt
128862 INFO: Excluding import 'PyQt4'
128871 INFO: Import to be excluded not found: 'FixTk'
128876 INFO: Import to be excluded not found: 'PySide'
128880 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
128897 INFO: Excluding import 'tkinter'
128903 INFO: Import to be excluded not found: 'FixTk'
128906 INFO: Loading module hook "hook-pkg_resources.py"...
129310 INFO: Processing pre-safe import module hook   win32com
129405 INFO: Processing pre-safe import module hook   win32com
129659 INFO: Excluding import '__main__'
129667 INFO:   Removing import of __main__ from module pkg_resources
129673 INFO: Loading module hook "hook-pycparser.py"...
129690 INFO: Loading module hook "hook-pydoc.py"...
129705 INFO: Loading module hook "hook-pytz.py"...
129858 INFO: Loading module hook "hook-setuptools.py"...
130514 INFO: Loading module hook "hook-sqlite3.py"...
130693 INFO: Loading module hook "hook-sysconfig.py"...
130709 INFO: Loading module hook "hook-ttkthemes.py"...
131438 INFO: Loading module hook "hook-xml.dom.domreg.py"...
131457 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
131473 INFO: Loading module hook "hook-xml.py"...
131489 INFO: Loading module hook "hook-_tkinter.py"...
131780 INFO: checking Tree
131784 INFO: Building Tree because Tree-00.toc is non existent
131791 INFO: Building Tree Tree-00.toc
132037 INFO: checking Tree
132043 INFO: Building Tree because Tree-01.toc is non existent
132050 INFO: Building Tree Tree-01.toc
132150 INFO: Looking for ctypes DLLs
132223 INFO: Analyzing run-time hooks ...
132235 INFO: Including run-time hook 'pyi_rth_certifi.py'
132253 INFO: Including run-time hook 'pyi_rth_pkgres.py'
132272 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
132289 INFO: Including run-time hook 'pyi_rth__tkinter.py'
132324 INFO: Looking for dynamic libraries
134254 INFO: Looking for eggs
134258 INFO: Using Python library c:\users\bk\appdata\local\programs\python\python37\python37.dll
134267 INFO: Found binding redirects: 
[]
134295 INFO: Warnings written to C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\build\app\warn-app.txt
134488 INFO: Graph cross-reference written to C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\build\app\xref-app.html
134710 INFO: checking PYZ
134715 INFO: Building PYZ because PYZ-00.toc is non existent
134722 INFO: Building PYZ (ZlibArchive) C:\Users\bk250256\AppData\Local\Temp\tmphyctj9hl\build\app\PYZ-00.pyz
136460 INFO: Building PYZ (ZlibArchive) C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\build\app\PYZ-00.pyz completed successfully.
136507 INFO: checking PKG
136510 INFO: Building PKG because PKG-00.toc is non existent
136516 INFO: Building PKG (CArchive) PKG-00.pkg
166136 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
166266 INFO: Bootloader c:\users\bk\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
166273 INFO: checking EXE
166278 INFO: Building EXE because EXE-00.toc is non existent
166287 INFO: Building EXE from EXE-00.toc
166339 INFO: Copying icons from ['C:\\Users\\bk\\Desktop\\Source H\\logo.ico']
166347 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
166353 INFO: Writing RT_ICON 1 resource with 133960 bytes
166372 INFO: Updating manifest in C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\build\app\runw.exe.85edix34
166378 INFO: Updating resource type 24 name 1 language 0
166396 INFO: Appending archive to EXE C:\Users\bk\AppData\Local\Temp\tmphyctj9hl\application\app.exe
166435 INFO: Building EXE from EXE-00.toc completed successfully.

Moving project to: C:\Users\bk\output
Complete.

Hello everyone please help me,

I'm trying to compile my python app to one file exe, so far compile is successful, however when I try to run the app I get the fatal error, my app won't run.

Please help, I'll provide more info if needed.

At first I was thinking because i used python 3.8 version, then I downgraded to 3.7.4 and it still won't run.

I'm using auto-py-to-exe, I did try at first to use py2exe but I think it does not support python above 3.4 version.

Edit:

When I compile as One folder instead one file:

my app still wont run with following popup window again:

enter image description here

Update: I decided on trying to compile with the "console on" the option to see what is causing my program not to run, then this error comes via CMD.

Microsoft Windows [Version 10.0.17763.1132] (c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\bk>auto-py-to-exe
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'

C:\Users\bk>

Edit, new update:

after running with --debug,

I'm getting this error:

enter image description here

I will research this issue if I find a solution I will post it here.



Solution 1:[1]

Edit the filename.spec and add the missing module inside hidden import. Example:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis(['test.py'],
             pathex=['D:\\desktop\\finalfinalshort'],
             binaries=[],
             datas=[],
             hiddenimports=['winreg','win32gui','win32con'], #this are sample imports
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='test',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=False )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='test')

Then try pyinstaller filename.spec. That should work. Also, install the win32com with pip install pywin32.

Solution 2:[2]

Update,

130319 INFO: Excluding import 'PyQt4'
130326 INFO: Excluding import 'tkinter'
130334 INFO:   Removing import of tkinter from module PIL.ImageTk
130338 INFO: Import to be excluded not found: 'FixTk'
130342 INFO: Import to be excluded not found: 'PySide'
130345 INFO: Excluding import 'PyQt5'
130351 INFO:   Removing import of PyQt5 from module PIL.ImageQt
130356 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
130364 INFO: Excluding import 'tkinter'
130375 INFO: Import to be excluded not found: 'FixTk'
130378 INFO: Loading module hook "hook-pkg_resources.py"...
130942 INFO: Processing pre-safe import module hook   win32com

I advised in the above post I tried to include missing modules. But nothing seems to help, I'm always getting this "INFO" when trying to compile.

126021 WARNING: Unable to find package for requirement greenlet from package gevent.
126025 INFO: Packages required by gevent:
['cffi']

This is another interesting thing, it's trying to find event and my app isn't even using it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Klien Menard
Solution 2 Boris Klenovsek