Search code examples
windowswxpythoncx-freezepython-3.7

How to use cx_freeze with wxPython?


I can't get cx_freeze to turn the simplest wxPython app to an .exe file. I'd like to know how to proceed.

I'm using Python 3.6.8, wxPython 4.0.4 msw (phoenix) wxWidgets 3.0.5 and Windows 10. I've tried freezing a complex wx App, it did not work so I tried with the simplest app I could think of.

Here's my wx app :

import wx

app = wx.App()
frm = wx.Frame(None, title="Hello World")
frm.Show()
app.MainLoop()

and here's the setup for cx_freeze :

from cx_Freeze import setup, Executable

build_exe_options = {
    "packages": ["os", "wx"],
    "excludes": ["tkinter"]}

setup(name="simplewxapp",
      version="1",
      description="simplewxapp",
      options={"build_exe": build_exe_options},
      executables=[Executable("simplewxapp.py", base="Win32GUI")])

When I use this command : python setup.py build I expect it to work correctly (as it does when I don't use wxPython). Instead, I get this error message :

 File "C:\Program Files\Python36\lib\site-packages\win32\lib\win32verstamp.py", line 159, in stamp
    h = BeginUpdateResource(pathname, 0)
pywintypes.error: (2, 'BeginUpdateResource', 'Le fichier spécifié est introuvable.')

Solution

  • I also tried it with cx freeze the first time. No success on my side as well! I use pyinstaller at the moment and after some tweaks it is working perfectly fine.

    You can find it here: https://www.pyinstaller.org/