My cx_Freeze
app closes when I open it and no errors print. The setup file runs with no errors. I believe it has something to do with imports in my main code. I used python 3.6.5 cx_Freeze 6.0b1 and windows 10.
setup.py
import os
from cx_Freeze import setup, Executable
include_lst = []
package_lst = ['numpy', 'scipy', 'pulp', 'pubsub', 'sqlite3', 'pandas',
'wx', 'functools', 'sklearn', 'numpy.core._methods']
exclude_lst = ['matplotlib', 'tkinter', 'PyQt4.QtSql', 'PyQt5',
'PyQt4.QtNetwork', 'PyQt4.QtScript', 'sqlalchemy']
base = None
setup (
name='test',
version='0.01',
author='test',
author_email='Omitted',
options={'build_exe':
{'packages': package_lst,
'excludes': exclude_lst,
'include_files': include_lst
}
},
executables=[Executable('main_.py', base=base, icon=icon_file)]
)
When I freeze this basic example it works without any issues
main.py
import wx
class MasterPage (wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.createFrame()
def createFrame(self):
self.width, self.height = wx.GetDisplaySize()
self.SetTitle('Test')
self.SetSize(wx.Size((self.width-50, self.height-50)))
self.SetMinSize((1080, 720))
self.W, self.H = self.GetSize()
self.Bind(wx.EVT_CLOSE, self.onQuit)
self.Centre()
def onQuit(self, event):
"""Checks to make sure the user wants to leave the program"""
dlg = wx.MessageDialog(self,'Do you really want to quit?',
'Confirm Exit',
wx.ICON_QUESTION|wx.OK|wx.CANCEL )
result = dlg.ShowModal()
dlg.Destroy
if result == wx.ID_OK:
self.Destroy()
if __name__.endswith('__main__'):
app = wx.App()
MasterPage(None).Show()
app.MainLoop()
But when I add the import pandas
or import <any module>
above the import wx
line the cx_Freeze
app closes as soon as I open it
main.py
import pandas
import wx
class MasterPage (wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.createFrame()
def createFrame(self):
self.width, self.height = wx.GetDisplaySize()
self.SetTitle('Test')
self.SetSize(wx.Size((self.width-50, self.height-50)))
self.SetMinSize((1080, 720))
self.W, self.H = self.GetSize()
self.Bind(wx.EVT_CLOSE, self.onQuit)
self.Centre()
def onQuit(self, event):
"""Checks to make sure the user wants to leave the program"""
dlg = wx.MessageDialog(self,'Do you really want to quit?',
'Confirm Exit',
wx.ICON_QUESTION|wx.OK|wx.CANCEL )
result = dlg.ShowModal()
dlg.Destroy
if result == wx.ID_OK:
self.Destroy()
if __name__.endswith('__main__'):
app = wx.App()
MasterPage(None).Show()
app.MainLoop()
I have also tried to put the import in a try except statement it still will not open and no errors print
main.py
try:
import pandas
except Exception as e:
print(e)
import wx
class MasterPage (wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.createFrame()
def createFrame(self):
self.width, self.height = wx.GetDisplaySize()
self.SetTitle('Test')
self.SetSize(wx.Size((self.width-50, self.height-50)))
self.SetMinSize((1080, 720))
self.W, self.H = self.GetSize()
self.Bind(wx.EVT_CLOSE, self.onQuit)
self.Centre()
def onQuit(self, event):
"""Checks to make sure the user wants to leave the program"""
dlg = wx.MessageDialog(self,'Do you really want to quit?',
'Confirm Exit',
wx.ICON_QUESTION|wx.OK|wx.CANCEL )
result = dlg.ShowModal()
dlg.Destroy
if result == wx.ID_OK:
self.Destroy()
if __name__.endswith('__main__'):
app = wx.App()
MasterPage(None).Show()
app.MainLoop()
I even included a print statement before the import
statement and after the import
statement the first print statement runs then the app closes.
main.py
print('app started')
import pandas
print('import worked')
import wx
class MasterPage (wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.createFrame()
def createFrame(self):
self.width, self.height = wx.GetDisplaySize()
self.SetTitle('Test')
self.SetSize(wx.Size((self.width-50, self.height-50)))
self.SetMinSize((1080, 720))
self.W, self.H = self.GetSize()
self.Bind(wx.EVT_CLOSE, self.onQuit)
self.Centre()
def onQuit(self, event):
"""Checks to make sure the user wants to leave the program"""
dlg = wx.MessageDialog(self,'Do you really want to quit?',
'Confirm Exit',
wx.ICON_QUESTION|wx.OK|wx.CANCEL )
result = dlg.ShowModal()
dlg.Destroy
if result == wx.ID_OK:
self.Destroy()
if __name__.endswith('__main__'):
app = wx.App()
MasterPage(None).Show()
app.MainLoop()