Running Dash in debugging mode fails during reloading when there's a namespace package present.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Describe your context
dash 2.0.0
dash-bootstrap-components 0.13.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-renderer 1.9.1
dash-table 5.0.0
Describe the bug
Running Dash in debugging mode fails during reloading when there's a namespace package present. I received this traceback:
Traceback (most recent call last):
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\marvinw\.vscode\extensions\ms-python.python-2021.6.944021595\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\Users\marvinw\.vscode\extensions\ms-python.python-2021.6.944021595\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\marvinw\.vscode\extensions\ms-python.python-2021.6.944021595\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\marvinw\Desktop\Git\sap-explorer\dash\index.py", line 43, in <module>
app.run_server(debug=True)
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\site-packages\dash\dash.py", line 1958, in run_server
debug = self.enable_dev_tools(
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\site-packages\dash\dash.py", line 1721, in enable_dev_tools
component_packages_dist = [
File "C:\Users\marvinw\.conda\envs\sap-explorer\lib\site-packages\dash\dash.py", line 1726, in <listcomp>
else package.filename
AttributeError: '_NamespaceLoader' object has no attribute 'filename'
Where I had a namespace package in the same directory. Adding an empty __init__.py to that folder to convert it from a namespace package to a normal package (background info: https://stackoverflow.com/a/48804718/6068036) fixed this error, but imho dash shouldn't block users from also using namespace packages.
Similar issue as in https://github.com/cherrypy/cherrypy/issues/1697.
Expected behavior
Users should be able to use dash, while also having a namespace package in the working directory.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in dash/dash.py at enable_dev_tools around lines 1721-1726, where component package filenames are collected. Reproduce debug reloading with a namespace package present and trace the failing loader access. Done means Dash reloads without AttributeError while the namespace package remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100