Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot run debug=True when sub classing html or dcc components #1285

Closed
gioxc88 opened this issue May 28, 2020 · 2 comments · Fixed by #1288
Closed

[BUG] Cannot run debug=True when sub classing html or dcc components #1285

gioxc88 opened this issue May 28, 2020 · 2 comments · Fixed by #1288
Labels
bug something broken

Comments

@gioxc88
Copy link

gioxc88 commented May 28, 2020

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)

@alexcjohnson
Copy link
Collaborator

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?

@alexcjohnson alexcjohnson added the bug something broken label May 28, 2020
@gioxc88
Copy link
Author

gioxc88 commented May 28, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants