title: Unable to convert wxPython based GUI to .exe file using pyinstaller in Python 2.7
body: <p>I have been trying to convert my wxPython based python script into a .exe file using PyInstaller but I have not been successful yet. A .exe file is created after the conversion but an errors message saying "Failed to execute script main" pops us as soon as I click on the .exe file. </p>
  
  <p>My code is as follow :</p>
  
  <pre><code>import wx
  import sys
  
  class MyAppWindow(wx.Frame):
  
  
  
      def __init__(self, title='Path Finder'):
          '''
          Constructor
          '''
          wx.Frame.__init__(self, None, 111, title, size=(640,480))
  
          filemenu = wx.Menu()
          filemenu.Append(1,"&amp;About","Create a new file")
          filemenu.AppendSeparator()
          filemenu.Append(2,"&amp;Quit","Quit the Application")
          #Creating File menu 
          viewmenu = wx.Menu()
          viewmenu.Append(3,"&amp;Shrink","Reduce size to half")
          viewmenu.Append(4,"&amp;Maximize","Maximize window")
          viewmenu.Append(5,"&amp;Full screen","Switch to full screen mode")
          viewmenu.Append(6,"&amp;Reset","Reset View")
          #Creating view menu
          menubar = wx.MenuBar()
          menubar.Append(filemenu,"&amp;File")
          menubar.Append(viewmenu,"&amp;View")
          self.SetMenuBar(menubar)
          #Fitting File and edit in menu bar
          panel2 = wx.TextCtrl(self, 7, style=wx.TE_MULTILINE|wx.TE_READONLY)
          panel2.SetValue("Hello World! \nI am trying to make .exe files using Python!")
          # Created Panels
          vbox1 = wx.BoxSizer(wx.VERTICAL)
          #vbox1.Add(panel1, 1, wx.EXPAND)
          vbox1.Add(panel2, 2, wx.EXPAND)
          #vbox1.Add(panel3,1,wx.EXPAND)
          self.SetSizer(vbox1)
          #Sizr to adjust panel 
  
          wx.EVT_MENU(self, 2, self.onQuit)
          wx.EVT_MENU(self, 3, self.onViewShrink)
          wx.EVT_MENU(self, 4, self.onViewMaximize)
          wx.EVT_MENU(self, 5, self.onViewFullScreen)
          wx.EVT_MENU(self, 6, self.onViewReset)
          wx.EVT_MENU(self, 1, self.OnAbout) 
          #Associating the menu buttons with their respective functions 
          self.Show()
  
  
  
      def onQuit(self, e):
          print("Good bye!")
          self.Close()
      #Quits the GUI
  
      def onViewReset(self,e):
          self.ShowFullScreen(False)
          self.SetSize((640,480))
          self.Center()
      #Restes the GUI to center
  
      def onViewFullScreen(self,e):
          self.ShowFullScreen(True)
      #Full Screen 
  
      def onViewMaximize(self,e):
          self.Maximize(True)
      #Maximises the GUI 
  
      def onViewShrink(self,e):
          msize = []
          for i in self.GetSize():
              msize.append(int(0.75*i))
          self.SetSize(msize)
      #Shrinks the GUI
  
      def OnAbout(self, e):
          d = wx.MessageDialog(self, "Program to learn Python to exe conversion\n"
                         ,"Python to exe using PyInstaller", wx.OK)
          d.ShowModal()  # show the dialog
          d.Destroy() 
      #About menu 
  
      #----------------------------------------------------------------------
  myApp = wx.App()
  myFrame = MyAppWindow()
  myApp.MainLoop() 
  
  #End of Python script
  </code></pre>
  
  <p>The command I typed in command prompt is as follow: 
  pyinstaller.exe --onefile --windowed MyAppWindow.py</p>
  
  <p>Message displayed in the command prompt is as follow:</p>
  
  <pre><code>829 INFO: PyInstaller: 3.3.1
  830 INFO: Python: 2.7.11
  833 INFO: Platform: Windows-10-10.0.16299
  838 INFO: wrote C:\Users\Smit\workspace\Amobeo_GUI2exe\src\MyAppWindow.spec
  845 INFO: UPX is not available.
  856 INFO: Extending PYTHONPATH with paths
  ['C:\\Users\\Smit\\workspace\\Amobeo_GUI2exe\\src',
   'C:\\Users\\Smit\\workspace\\Amobeo_GUI2exe\\src']
  857 INFO: checking Analysis
  871 INFO: Building Analysis because out00-Analysis.toc is non existent
  873 INFO: Initializing module dependency graph...
  892 INFO: Initializing module graph hooks...
  1178 INFO: running Analysis out00-Analysis.toc
  1191 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
    required by c:\users\smit\appdata\local\enthought\canopy\system\scripts\python.exe
  1549 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4967_none_acd2fb3be1d90a9f.manifest
  1554 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_acd388d7e1d8689f.manifest
  1560 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_acce041fe1dd7bc9.manifest
  1937 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9317_none ...
  1942 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_08e0939fa840d57b.manifest
  2012 INFO: Searching for file msvcr90.dll
  2015 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_08e0939fa840d57b\msvcr90.dll
  2035 INFO: Searching for file msvcp90.dll
  2098 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_08e0939fa840d57b\msvcp90.dll
  2128 INFO: Searching for file msvcm90.dll
  2159 INFO: Found file C:\WINDOWS\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_08e0939fa840d57b\msvcm90.dll
  2560 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4967_none_acd2fb3be1d90a9f.manifest
  2570 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_acd388d7e1d8689f.manifest
  2580 INFO: Found C:\WINDOWS\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_acce041fe1dd7bc9.manifest
  2592 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -&gt; (9, 0, 30729, 9317)
  3097 INFO: Caching module hooks...
  3129 INFO: Analyzing C:\Users\Smit\workspace\Amobeo_GUI2exe\src\MyAppWindow.py
  3175 INFO: Loading module hooks...
  3179 INFO: Loading module hook "hook-encodings.py"...
  11202 INFO: Looking for ctypes DLLs
  11204 INFO: Analyzing run-time hooks ...
  11225 INFO: Looking for dynamic libraries
  11417 INFO: Looking for eggs
  11418 INFO: Using Python library c:\users\smit\appdata\local\enthought\canopy\system\scripts\python27.dll
  11420 INFO: Found binding redirects:
  [BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'amd64', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 9317), publicKeyToken=u'1fc8b3b9a1e18e3b')]
  11437 INFO: Warnings written to C:\Users\Smit\workspace\Amobeo_GUI2exe\src\build\MyAppWindow\warnMyAppWindow.txt
  11543 INFO: Graph cross-reference written to C:\Users\Smit\workspace\Amobeo_GUI2exe\src\build\MyAppWindow\xref-MyAppWindow.html
  11834 INFO: checking PYZ
  11836 INFO: Building PYZ because out00-PYZ.toc is non existent
  11838 INFO: Building PYZ (ZlibArchive) C:\Users\Smit\workspace\Amobeo_GUI2exe\src\build\MyAppWindow\out00-PYZ.pyz
  12781 INFO: Building PYZ (ZlibArchive) C:\Users\Smit\workspace\Amobeo_GUI2exe\src\build\MyAppWindow\out00-PYZ.pyz completed successfully.
  13014 INFO: checking PKG
  13016 INFO: Building PKG because out00-PKG.toc is non existent
  13018 INFO: Building PKG (CArchive) out00-PKG.pkg
  13146 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -&gt; (9, 0, 30729, 9317)
  18030 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
  18073 INFO: Bootloader c:\users\smit\appdata\local\enthought\canopy\system\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
  18076 INFO: checking EXE
  18079 INFO: Building EXE because out00-EXE.toc is non existent
  18081 INFO: Building EXE from out00-EXE.toc
  18084 INFO: Appending archive to EXE C:\Users\Smit\workspace\Amobeo_GUI2exe\src\dist\MyAppWindow.exe
  19056 INFO: Building EXE from out00-EXE.toc completed successfully.
  </code></pre>
  
  <p>(Image: <a href="https://i.stack.imgur.com/Di9qh.png" rel="nofollow noreferrer">Message displayed in command prompt</a>)</p>
  
  <p>The above procedure creates two folders in my source folders, namely 'build' and 'dist'. An exe file called MyAppWindow.exe is created inside the 'dist' folder. However, the following error message pops up when I click on it: </p>
  
  <p>Fatal Error!
  "Failed to execute MyAppWindow"
  (Image: <a href="https://i.stack.imgur.com/T8juM.png" rel="nofollow noreferrer">Error message</a>)</p>
  
  <p>My GUI looks like this when I run the Python script: 
  <a href="https://i.stack.imgur.com/fhwXq.png" rel="nofollow noreferrer">GUI created by the Python script</a></p>
  
  <p>I am using Python 2.7.11 --  64-bit on Windows</p>
  
  <p>I would be glad for your help. Please let me know if you have any questions.</p>