I know that --onefile is supposed to take longer than --onedir, but I'm not sure if it's to this extent.
The code I'm compiling is very basic
# pyinstaller --onedir --noconfirm --additional-hooks-dir=hooks --paths=venvLibsite-packages script_min.py
# pyinstaller --onedir --noconfirm --additional-hooks-dir=hooks --paths=venvLibsite-packages script_min.py
# pyinstaller --onedir --clean --additional-hooks-dir=hooks script_min.py
import dash
import plotly.graph_objs as go
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
server = app.server
labels = ["Oxygen", "Hydrogen", "Carbon_Dioxide", "Nitrogen"]
values = [4500, 2500, 1053, 500]
pie_fig = go.Figure(
data=[go.Pie(labels=labels, values=values)]
)
piechart = dcc.Graph(
figure=pie_fig
)
app.layout = html.Div([html.Div([piechart], className="row")])
if __name__ == "__main__":
app.run_server(debug=False)
Subsequently, I added the hooks as necessary in a folder
When I compile as --onedir
with pyinstaller --onedir --clean --additional-hooks-dir=hooks script_min.py
, the .exe in the directory runs in less than a second.
But when i compile as --onefile
with pyinstaller --onefile --clean --additional-hooks-dir=hooks script_min.py
, it takes over 5 minutes to run.
I'm pretty sure it shouldn't take this long, as I reference a similar (and even more complicated) project here, for which its --onefile
.exe runs in less than 10 seconds.
Whether I'm using hooks, or adding through datas/hidden-imports, the discrepancy is still present.
question from:
https://stackoverflow.com/questions/65623447/pyinstaller-onefile-takes-much-longer-than-onedir-plotly-dash 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…