Search code examples
pythonflaskpycharmplotly-dash

Why does Dash throw a TypeError when debugging through PyCharm?


When I try to run a Dash app from PyCharm in debug mode I keep getting the below TypeError. What can I do to fix this so that I can break on breakpoints in PyCharm?

I'm using: Dash 2.0.0, Python 3.9.6, PyCharm Community Edition 2021.1.3, Windows 10.

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\pydevd.py", 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\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/redacted/dashboard/dashboard.py", line 170, in <module>
    _app = dash.Dash(__name__, external_stylesheets=[dbc.themes.DARKLY])
  File "C:\redacted\.venv\lib\site-packages\dash\dash.py", line 304, in __init__
    self.server = flask.Flask(name) if server else None
  File "C:\redacted\.venv\lib\site-packages\flask\app.py", line 406, in __init__
    instance_path = self.auto_find_instance_path()
  File "C:\redacted\.venv\lib\site-packages\flask\app.py", line 638, in auto_find_instance_path
    prefix, package_path = find_package(self.import_name)
  File "C:\redacted\.venv\lib\site-packages\flask\scaffold.py", line 850, in find_package
    package_path = _find_package_path(root_mod_name)
  File "C:\redacted\.venv\lib\site-packages\flask\scaffold.py", line 801, in _find_package_path
    return os.path.dirname(next(iter(spec.submodule_search_locations)))
TypeError: 'NoneType' object is not iterable
python-BaseException

Process finished with exit code 1

Here's how I've setup my PyCharm run configuration:

enter image description here


Solution

  • Likely a bug in PyCharm. Solved by upgrading PyCharm to 2021.2.3.