Reputation: 63
I am new to pyinstaller but I got it to work and create an executable file.
The program runs in .22-.24 seconds on my dinky laptop from 2010.
I did the basic pyinstaller while keeping it as a pyinstaller myscript.py --onedir
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.
I've tried other formats like --onefile
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.
Here is the 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()
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.
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 from pandas import read_csv
make the exe run faster?
Thanks for the help!!
Upvotes: 1
Views: 2831
Reputation: 63
To anyone who runs into the same issue, it seems that I was correct! Or I got unlucky initially, but after removing all the non important libraries, my code runs much faster! It takes about 2 seconds vs 22. Not perfect but I'll take it.
So if possible, use from x import y
if you're focusing on speed!
What's interesting is pyinstaller even says it only downloads and runs used libraries but maybe there's some imperfection there. Anyways, hope this will help anyone in the future!
Upvotes: 2