I keep getting the following error when running the exe file generated from plotly-dash codes using PyInstaller.
AttributeError: 'FrozenImporter' object has no attribute 'filename'
Did some in-depth check, only able to identify the attribute error happened when dash is trying to import dash_renderer and retrieving the filename from the line package.filename
Tried adding the following but still unable to resolve
My plotly-dash codes
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H2(children='H-{} Meeting Dashboard'.format("SS"), style={'text-align':'center'}),
html.Div(children=[
html.Div('''Generated on {}'''.format(str(datetime.now())[:19]), style={'text-align':'center', 'font-size':'15px'})
], className='row')]
)
if __name__ == "__main__":
app.run_server(debug=True)
PyInstaller Codes used to generate the exe file
\path\to\python37\python.exe -m PyInstaller app_short.py
Error when running the .exe file, run into error below
my\directory>app_short.exe
2019-06-25 23:36:55 Imported all modules
Traceback (most recent call last):
File "app_short.py", line 24, in <module>
File "site-packages\dash\dash.py", line 1476, in run_server
File "site-packages\dash\dash.py", line 1361, in enable_dev_tools
File "site-packages\dash\dash.py", line 1359, in <listcomp>
AttributeError: 'FrozenImporter' object has no attribute 'filename'
[16716] Failed to execute script app_short
Running the app_short.py file was able to launch the flask app properly and the html page could be access, but the exe kept showing AttributeError.
\my\directory>app_short.py
2019-06-25 23:56:47 Imported all modules
Running on http://127.0.0.1:8050/
Debugger PIN: 313-047-004
* Serving Flask app "app_short" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
2019-06-25 23:56:51 Imported all modules
Running on http://127.0.0.1:8050/
Debugger PIN: 074-068-565
How do I fix this error?
I encountered the same error message, and I resolved it by changing
if __name__ == "__main__":
app.run_server(debug=True)
to
if __name__ == "__main__":
app.run_server(debug=False)
Not sure why this happens or if running with debug=False
is even possible for your needs! Maybe someone else can elaborate?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With