Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyinstaller: Execution fails when console is disabled

I am trying to package my tkinter application into a single file executable. Whenever I set the console option to False, I run into a message box that states that reads "Failed to execute script xxx". However, if I enable the console window in my .spec, I can run my program just fine.

I have included my spec file below. I execute the file with:

pyinstaller --onefile -w build.spec

spec file code:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['MainPage.py'],
             pathex=['C:\\path-to\\prog'],
             binaries=None,
             datas=None,
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
a.datas += [('icon.ico','C:\\path-to\\icon.ico','DATA')]
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='prog.exe',
          debug=False,
          strip=False,
          upx=False,
          console=False , icon='icon.ico')

Why is my application failing to execute when I change the console option?

like image 431
Samuel Doud Avatar asked Nov 09 '22 14:11

Samuel Doud


1 Answers

I ran into similar issue while using a module that was logging some information in console (progress bar). Once I disabled all information output to console, it was running fine.

You might want to check what actually happens in console when you use your app and disable/remove console interaction if you intend to run without it.

p.s. And next time I should check the post date first =P

like image 178
Mikhail Ilin Avatar answered Nov 15 '22 12:11

Mikhail Ilin