title: python .exe not working properly
body: <p>I downloaded pyinstaller in order to turn my python scripts into an executable program. I have a main script ((homepage.py) that, when ran, it would display a window with two buttons (button1 and button2). Each of the two buttons, if clicked, would run its corresponding python script (input1.py or input2.py) that displays a window where the user inputs data to be graphed in excel.</p>
  
  <p>My scripts work correctly when I run them in Spyder through Anaconda. However, when I turn my main script (Homepage.py) into an executable program and run it, the main window with the two buttons appear, but when I click any of the two buttons, the corresponding window does not appear and the program closes. Does anyone know why that would happen? Do I need to turn my input1.py and input2.py into .exe programs as well like I did with homepage.py?</p>
  
  <p>In my scripts, when I need click any of the buttons, I would hide the main window and show the new window. Would hiding and showing be what is causing my program to not function correctly even if it is working in Spyder?</p>
  
  <p>main window (homapge.py) imports and class name,</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  from input1 import Ui_input1
  from input2 import Ui_input2
  
  class Ui_homepage(object):
  </code></pre>
  
  <p>button1 (input1.py) imports and class name,</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  import csv, os, subprocess, output1
  
  class Ui_input1(object):
  </code></pre>
  
  <p>button2 (input2.py) imports and class name,</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  import csv, os, subprocess, output2
  
  class Ui_input2(object):
  </code></pre>
  
  <p>Also, inside both of input1.py and input2.py, I have a button function that returns to the main window (homepage.py) when clicked, and inside that function I import,</p>
  
  <pre><code>from homepage import Ui_homepage
  </code></pre>
  
  <p>At the end of homepage.py, input1.py, and input2.py I have this import,</p>
  
  <pre><code>if __name__ == "__main__":
      import sys
  </code></pre>
  
  <p>Let me know if you need any more clarification or code.</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>The code that I use in the main window (homepage.py) that calls button1,</p>
  
  <pre><code>self.button1.clicked.connect(self.displayWindow1)
  
  def displayWindow1(self):
      self.window = QtWidgets.QMainWindow()
      self.uiInput1 = Ui_input1()
      self.uiInput1.setupUi(self.window)
      self.homepage.hide()
      self.window.showMaximized()
  </code></pre>
  
  <p>The code that I use in the main window (homepage.py) that calls button2,</p>
  
  <pre><code>self.button2.clicked.connect(self.displayWindow2)
  
  def displayWindow1(self):
      self.window = QtWidgets.QMainWindow()
      self.uiInput2 = Ui_input1()
      self.uiInput2.setupUi(self.window)
      self.homepage.hide()
      self.window.showMaximized()
  </code></pre>
  
  <p><strong>EDIT 2</strong>:</p>
  
  <p>I tried running the program after I changed,</p>
  
  <pre><code>from input1 import Ui_input1
  from input2 import Ui_input2
  </code></pre>
  
  <p>to,</p>
  
  <pre><code>import input1 
  import input2
  </code></pre>
  
  <p>I got this error in the command prompt window after typing <strong>pyinstaller --onefile --windowed homepage.exe</strong>,</p>
  
  <pre><code>25160 WARNING: lib not found: MSVCR90.dll dependency of c:\users\bj914e
  \appdata\local\continuum\anaconda3\Library\bin\zlib.dll
  </code></pre>
  
  <p>and I got these errors in a warnhomepage.txt file,</p>
  
  <pre><code>missing module named resource - imported by posix, C:\Users\bj914e\Desktop
  \DAMS\DAMS_Version_4\homepage.py
  missing module named posix - imported by os, C:\Users\bj914e\Desktop
  \DAMS\DAMS_Version_4\homepage.py
  missing module named _posixsubprocess - imported by subprocess, C:\Users
  \bj914e\Desktop\DAMS\DAMS_Version_4\homepage.py
  missing module named org - imported by pickle, C:\Users\bj914e\Desktop
  \DAMS\DAMS_Version_4\homepage.py
  missing module named readline - imported by cmd, code, pdb, C:\Users
  \bj914e\Desktop\DAMS\DAMS_Version_4\homepage.py
  excluded module named _frozen_importlib - imported by importlib, 
  importlib.abc, C:\Users\bj914e\Desktop\DAMS\DAMS_Version_4\homepage.py
  missing module named _frozen_importlib_external - imported by 
  importlib._bootstrap, importlib, importlib.abc, C:\Users\bj914e\Desktop
  \DAMS\DAMS_Version_4\homepage.py
  missing module named _winreg - imported by platform, C:\Users\bj914e
  \Desktop\DAMS\DAMS_Version_4\homepage.py
  missing module named _scproxy - imported by urllib.request
  missing module named java - imported by platform, C:\Users\bj914e\Desktop
  \DAMS\DAMS_Version_4\homepage.py
  missing module named 'java.lang' - imported by platform, C:\Users\bj914e
  \Desktop\DAMS\DAMS_Version_4\homepage.py, xml.sax._exceptions
  missing module named vms_lib - imported by platform, C:\Users\bj914e
  \Desktop\DAMS\DAMS_Version_4\homepage.py
  missing module named termios - imported by tty, C:\Users\bj914e\Desktop
  \DAMS\DAMS_Version_4\homepage.py, getpass
  missing module named grp - imported by shutil, tarfile, C:\Users\bj914e
  \Desktop\DAMS\DAMS_Version_4\homepage.py
  missing module named pwd - imported by posixpath, shutil, tarfile, 
  http.server, webbrowser, C:\Users\bj914e\Desktop\DAMS\DAMS_Version_4
  \homepage.py, netrc, getpass
  missing module named _dummy_threading - imported by dummy_threading, 
  C:\Users\bj914e\Desktop\DAMS\DAMS_Version_4\homepage.py
  missing module named 'org.python' - imported by copy, C:\Users\bj914e
  \Desktop\DAMS\DAMS_Version_4\homepage.py, xml.sax
  missing module named cPickle - imported by xlsxwriter.compat_collections
  missing module named cStringIO - imported by cPickle
  missing module named copy_reg - imported by cPickle, cStringIO
  missing module named StringIO - imported by xlsxwriter.compatibility
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I was able to fix my problem. It turned out to be a very simple solution. After I clicked one of the buttons the program closed, but a command prompt window appeared and disappeared within a millisecond that I did not notice before until it was mentioned to me in the solution below. The solution was moving <strong>all</strong> of the data files that input1.py and input2.py use into the dist file with the .exe program.</p>
  
  <p>P.S: some recording programs are too slow to record the window that appears and disappears, so I tried with my smartphone (iPhone) camera and it was able to detect it.</p>