title: Python- Why does my executable program take a long time to load after creating it with pyinstaller?
body: <p>I am new to pyinstaller but I got it to work and create an executable file.</p>
  
  <p>The program runs in .22-.24 seconds on my dinky laptop from 2010.</p>
  
  <p>I did the basic pyinstaller while keeping it as a <code>pyinstaller myscript.py --onedir</code> as this was explained to be the fastest method for running it. Regardless of this, the file opens to the black .exe box and loads for about 22 seconds before finally opening my tkinter text box.</p>
  
  <p>I've tried other formats like <code>--onefile</code> but that takes a hilarious 95 seconds to open. I've tried optimizing my code as much as possible and got the run time to .27 to an impressive .22 (sarcasm). The .exe still takes the same amount of time to load.</p>
  
  <p>Here is the code</p>
  
  <pre><code> import os
   import sys
   import shutil
   import pandas as pd
   import string
   import re
   from tkinter import *
   global lot
   def main():
      window=Tk()
      .... foo
   def lot_check():
      lot=lot.var
      ... foo
   def Lot_Error():
      window1=Tk()
      ... foo
  
   def clicked():
      lot=txt.get()
      lot=lot.upper()
          pass
      else:
          Lot_Error()
      lot=''.join(L)
      counter=pd.read_csv('F:foo,header=None,)
  
      r = re.compile("([a-zA-Z]+)([0-9]+)")
      counter_value=r.match(counter.iloc[0,0])
      ... foo
      letter=string.ascii_uppercase[counter_letter_converted]
      ...foo
      counter.iloc[0,0]=m
      counter.to_csv('F:Foo0', encoding='utf-8',header=False,index=False)    
      shutil.copyfile(F:Foo, 'F:Foo2)
      file='Foo2'
      os.startfile(file)
      window.destroy()
   main()
   window.mainloop()
  </code></pre>
  
  <p>I apologize for all the code but I wanted to include all the libraries and libraries I call. I also wanted to include some extra stuff in case there's something I'm doing that is causing this issue. </p>
  
  <p>My only guess would be that I'm importing too many libraries and that pyinstaller makes them fully load every time it's run. Would doing something like <code>from pandas import read_csv</code> make the exe run faster?</p>
  
  <p>Thanks for the help!!</p>