title: cx_freeze executable quickly opens and closes without doing what the script is supposed to do
body: <p>First off, I am brand new to programming, python, and this forum so sorry for any mistakes.</p>
  
  <p>I wrote a python script but want to be able to run it on a computer without python installed, so I did some research and found I would need to download a program in order to convert py to exe.  cx_freeze was the only one that supported python 3.4.</p>
  
  <p>I followed the instructions in a popular YouTube video (<a href="https://www.youtube.com/watch?v=XHcDHSWRCRQ" rel="nofollow noreferrer">https://www.youtube.com/watch?v=XHcDHSWRCRQ</a>) but when I double click the exe, the command box pops open for a split second and then closes.  There is some text but it goes too quickly for me to read it.</p>
  
  <p>It looks like these threads are about the same problem but they went unanswered.  Any ideas?</p>
  
  <p><a href="https://stackoverflow.com/questions/19472973/command-prompt-disappears-with-cx-freeze">Command prompt disappears with cx_freeze</a></p>
  
  <p><a href="https://stackoverflow.com/questions/23000282/cx-freeze-exe-file-opens-for-a-second-then-closes">cx_Freeze exe file opens for a second then closes</a></p>
  
  <p>Thanks!</p>
  
  <p>Edit:  If it helps, here is my setup.py</p>
  
  <pre><code>from cx_Freeze import setup, Executable
  
  setup(
  name = "Teacher Pages Search" ,
  version = "1" ,
  description = "By Gambiteer" , executables = [Executable("Teacher Pages Search.py")] ,
  )
  </code></pre>
  
  <p>Here is Teacher Pages Search.py</p>
  
  <pre><code>import urllib.request
  import html.parser
  import webbrowser
  
  class MyHTMLParser(html.parser.HTMLParser):
      def __init__(self):
          super().__init__(False)
          self.teacherLink = False
          self.url = ""
  
      def handle_starttag(self, tag, attrs):
          if tag == 'a':
              for combo in attrs:
                  if "sw-directory-item" in combo[1]:
                      self.teacherLink = True
                  if self.teacherLink is True:
                      if "http:" in combo[1]:
                          self.url = combo[1]
  
  
      def handle_data(self, data):
          data = data.lower()
          data = data.replace("'","")
          data = data.replace("\\","")
          data = data.replace(" ","")
          if self.teacherLink is True:
              for teacher in teacherList:
                  if teacher in data:
                      webbrowser.open(self.url)
          self.teacherLink = False
  
  
  teacherListInput = input("Enter the last name of your teachers, without punctuation, separated by commas:\n")
  teacherListInput = teacherListInput.replace(" ","")
  teacherList = list()
  while teacherListInput.find(',') != -1:
      commaLoc = teacherListInput.find(',')
      teacherName = teacherListInput[0:commaLoc]
      teacherList.append(teacherName)
      teacherListInput = teacherListInput[commaLoc+1:]
  teacherList.append(teacherListInput)
  
  f = urllib.request.urlopen("http://www.scarsdaleschools.k12.ny.us/site/Default.aspx?PageType=1&amp;SiteID=65&amp;ChannelID=94&amp;DirectoryType=6")
  webpage = f.read()
  parser = MyHTMLParser()
  html_parser = html.parser.HTMLParser()
  unescaped = html_parser.unescape(str(webpage))
  parser.feed(unescaped)
  
  input("Press enter to exit")
  </code></pre>