✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Debug mode breaks when subclassing dash_core_component

I would like to subclass the dash_core_components Graph class to add the ability to automatically download the data shown on the graph. I have this functionality working but it appears to break dash debug mode. I have narrowed this down to any class that inherits from dcc.Graph fails in debug with:

 raise ImportError(msg.format(fullname, type(ex), ex)) from ex
ImportError: Error while finding loader for '__main__' (<class 'ValueError'>: __main__.__spec__ is None)

The minimal example below works fine when debug=False but fails as written

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash('MyDashApp')
app.layout = html.Div('test')

class SubclassGraph(dcc.Graph):


  • dash 1.11.0
  • dash_core_components 1.9.0
  • dash_html_components 1.0.3

Please advise how to properly subclass dash_core_components.

1 Like

Can anyone confirm if they see the same issue? Perhaps this is a bug with my environment.


if __name__ == '__main__':

Thanks ceuzebio but unfortunately this does not help. Does my example run successfully for you?

Can anyone else confirm if they also see this failure?

Anyone? Or am I doing something incredibly stupid?

Same thing here exactly
Cannot use debug mode when subclassing

Solved here https://github.com/plotly/dash/issues/1285
Put the subclasses in another module