Dash: [BUG] Cannot run debug=True when sub classing html or dcc components

Created on 28 May 2020  路  2Comments  路  Source: plotly/dash

python 3.7.7
dash                 1.11.0
dash-core-components 1.9.1
dash-html-components 1.0.3
dash-renderer        01.4.0
dash-table           4.6.2

Whenever I try to subclass a component I cannot use the app in debug mode.
Unfortunately it becomes unusable without debug mode when developing.

This is the full traceback

Traceback (most recent call last):
  File "C:\Users\gioxc\AppData\Local\Programs\Python\Python37\lib\pkgutil.py", line 493, in find_loader
    spec = importlib.util.find_spec(fullname)
  File "C:\Users\gioxc\AppData\Local\Programs\Python\Python37\lib\importlib\util.py", line 114, in find_spec
    raise ValueError('{}.__spec__ is None'.format(name))
ValueError: __main__.__spec__ is None

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "apptest.py", line 108, in <module>
    app.run_server(debug=True)
  File "C:\Users\gioxc\AppData\Local\Programs\Python\Python37\lib\site-packages\dash\dash.py", line 1475, in run_server
    dev_tools_prune_errors,
  File "C:\Users\gioxc\AppData\Local\Programs\Python\Python37\lib\site-packages\dash\dash.py", line 1282, in enable_dev_tools
    for x in list(ComponentRegistry.registry) + ["dash_renderer"]
  File "C:\Users\gioxc\AppData\Local\Programs\Python\Python37\lib\site-packages\dash\dash.py", line 1277, in <listcomp>
    os.path.dirname(package.path)
  File "C:\Users\gioxc\AppData\Local\Programs\Python\Python37\lib\site-packages\dash\dash.py", line 1282, in <genexpr>
    for x in list(ComponentRegistry.registry) + ["dash_renderer"]
  File "C:\Users\gioxc\AppData\Local\Programs\Python\Python37\lib\pkgutil.py", line 499, in find_loader
    raise ImportError(msg.format(fullname, type(ex), ex)) from ex
ImportError: Error while finding loader for '__main__' (<class 'ValueError'>: __main__.__spec__ is None)

bug

All 2 comments

Oh interesting - I guess the subclass is defined in the main app file itself? Not a use case we've encountered before but I guess we can filter out __main__ from this list. I wonder if there are any other cases pkgutil.find_loader will fail?

Meantime perhaps you can just put the subclass in a separate file?

Hei @alexcjohnson many thanks for the answer!!
Yes you are right I didn't realize this was the problem. Working now!!!

by the way I also found another guy with the same issue here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ricardo-C-Oliveira picture Ricardo-C-Oliveira  路  4Comments

Marc-Andre-Rivet picture Marc-Andre-Rivet  路  3Comments

germayneng picture germayneng  路  4Comments

r-chris picture r-chris  路  3Comments

AngusCui picture AngusCui  路  3Comments