title: pyInstaller loads script multiple times
body: <p>I've managed to get pyinstaller to run more or less correctly now, except that it opens too many windows. It's pygame project, and it keeps loading the entire thing over again every second or so. My PC fills with game windows after a few seconds and everything grinds to a halt.</p>
  
  <p>Running it from commandline, I can just see print outs saying the app is starting pasted over and over again in commandline window. As far as I can tell the Apps aren't closing or exiting, just spawning more and more.</p>
  
  <p>The command I call to start pyinstaller is this:</p>
  
  <pre><code>pyinstaller --onedir main_local.py
  </code></pre>
  
  <p>The main file looks like this:</p>
  
  <pre><code># Library imports
  import pygame
  
  # Project imports
  from multiroidal_client    import MultiroidalClient
  from settings              import *
  import time
  
  # Main program function
  def main():
  
      # Initialise game class
      game = MultiroidalClient(SCREEN_SIZE, ('127.0.0.1', 8080))
  
      # Start game loop
      game.main_game_loop()
  
  
  # Execute main function
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>I tried commenting out the if __ name __ ... bit to see if for some reason it was executing the main function and calling a duplicate each time by accident or something. When commented out the exec does nothing, as you might expect.</p>
  
  <p>Any ideas? I've not included any more code because there is loads of it, and I'm not sure which parts are relevant. Let me know if you need to see anything else.</p>
  
  <p>Cheers</p>
  
  <p>EDIT: I added a quick print after the game.main_game_loop() just to check if the script jumped out of the infinite game loop. No such luck. It's loading a parallel instances of the scripts, all running simultaneously.</p>
  
  <p>EDIT: I looked through the pyinstaller docs and managed to get some more debug out. Not sure if it's relevant or not, but here it is. This screen of dialog just keeps reprinting over and over again. I also tried the --noupx option which can sometimes help apparently - no such luck.</p>
  
  <p><a href="https://i.stack.imgur.com/FWgqa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FWgqa.png" alt="enter image description here"></a></p>