I want to make a one-file exe from a python script using Dash.
I have an analogous app that uses flask and it works.
Using Dash instead, when I run the generated exe file, I get the following error and I can't solve it.
Could you help me?
I had the exact same problem with the Temp folder, I don't know exactly why. I don't think I found the best solution, but I solved it by using a spec file for compilation and by adding all the packages that caused this error (all dash packages and plotly) to the data
argument.
As explained here, you can create a spec file to run pyinstaller like the command line instruction by running : pyi-makespec options name.py [other scripts …]
, with options like --onefile
.
It will create a spec file, with a Analysis constructor, where you can say to pyinstaller where to search for any package with a list of tuples datas=[('<path to the package>', '<name of the package>'), ...]
.
Your error seems to come from dash for you so something like this, depending of where is the dash package you're using (for me in a venv) :
a = Analysis(['script.py'],
pathex=[],
binaries=[],
datas=[('D:\\xxxxxx\\venv\\Lib\\site-packages\\dash', 'dash')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
If you use other dash packages like dbc or plotly I think you will have the same errors with those packages, so you'll have to add their path to the spec file too.