Use Pycharm Debugger when Dash app is running

Hey there,

I’m new to web development so my Flask understanding is very limited. I don’t even know if my question is naive or not.

I would like to be able to use Pycharm debugger when my dash webapp is running in the browser

For example, in my Dash-app, I do API call to load data. Is it possible to set a breakpoint on the line of the API call and launch the Pycharm debugger when that line is used?

Thanks in advance for anyone responding,

Works Great!


Thanks pmoran, could you also upload a picture of your Run/Debug Configuration please :slight_smile:

Sure here it is:
Note that I use Python 3.6 in a virtual env.
The requirements.txt is

dash==0.34.0 # The core dash backend
dash-html-components==0.13.4 # HTML components
dash-core-components==0.42.0 # Supercharged components
dash-table==3.1.11 # Interactive DataTable component (new!)

Thanks a lot!! It wasn’t working for me, breakpoints were not triggering the Pycharm debugger.

I have fixed this, but I’m not sure what was wrong because I didn’t have to change anything for it to work. I just tried lots of different stuff and when I went back to my original setting (same as yours), it suddenly worked…

Did u ever figure out what went wrong … i am having the same problems where the breakpoints after the plotly call to make_subplots are not working … the breakpoint just before that works fine! Thanks Anjan

For me, the debugger crashes with this traceback:

...\.venv\Scripts\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\" --multiproc --qt-support=auto --client --port 54662 --file ...results/dashboard/
Connected to pydev debugger (build 212.4746.96)
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\_pydev_imps\", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/dev/github/urig/entropy/entropylab/results/dashboard/", line 93, in <module>
    _app = dash.Dash(__name__)
  File "C:\dev\github\urig\entropy\.venv\lib\site-packages\dash\", line 304, in __init__
    self.server = flask.Flask(name) if server else None
  File "C:\dev\github\urig\entropy\.venv\lib\site-packages\flask\", line 406, in __init__
    instance_path = self.auto_find_instance_path()
  File "C:\dev\github\urig\entropy\.venv\lib\site-packages\flask\", line 638, in auto_find_instance_path
    prefix, package_path = find_package(self.import_name)
  File "C:\dev\github\urig\entropy\.venv\lib\site-packages\flask\", line 850, in find_package
    package_path = _find_package_path(root_mod_name)
  File "C:\dev\github\urig\entropy\.venv\lib\site-packages\flask\", line 801, in _find_package_path
    return os.path.dirname(next(iter(spec.submodule_search_locations)))
TypeError: 'NoneType' object is not iterable

This is on PyCharm Community Edition 2021.1.3, dash v2.0.0

Would appreciate any ideas on how to fix. Thanks!