After upgrading dash to 2.0.0 and updating the code to fix depreciation warnings, when I try to access my app I get a response that just says “Error loading layout”. The log file has the following unhelpful traceback (slightly redacted for proprietary information):
ERROR - 2021-09-09 11:19:22,662 - navigator.app - app - app.py - log_exception - 14052 - 26024 - Exception on /Developer Testing/App/1/_dash-layout [GET] Traceback (most recent call last): File "c:\desktop\environment\python\lib\site-packages\flask\app.py", line 2070, in wsgi_app response = self.full_dispatch_request() File "c:\desktop\environment\python\lib\site-packages\flask\app.py", line 1515, in full_dispatch_request rv = self.handle_user_exception(e) File "c:\desktop\environment\python\lib\site-packages\flask\app.py", line 1513, in full_dispatch_request rv = self.dispatch_request() File "c:\desktop\environment\python\lib\site-packages\flask\app.py", line 1499, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "c:\desktop\environment\python\lib\site-packages\flask_login\utils.py", line 261, in decorated_view return func(*args, **kwargs) File "c:\desktop\environment\python\lib\site-packages\dash\dash.py", line 560, in serve_layout to_json(layout), File "c:\desktop\environment\python\lib\site-packages\dash\_utils.py", line 21, in to_json return to_json_plotly(value) File "c:\desktop\environment\python\lib\site-packages\plotly\io\_json.py", line 124, in to_json_plotly return json.dumps(plotly_object, cls=PlotlyJSONEncoder, **opts) File "c:\desktop\environment\python\lib\json\__init__.py", line 238, in dumps **kw).encode(obj) File "c:\desktop\environment\python\lib\site-packages\_plotly_utils\utils.py", line 59, in encode encoded_o = super(PlotlyJSONEncoder, self).encode(o) File "c:\desktop\environment\python\lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "c:\desktop\environment\python\lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) TypeError: '<' not supported between instances of 'str' and 'int'
I was able to resolve the issue by installing orjson. I was able to run another dash app successfully in 2.0.0 so the error must be caused by something specific to my large dash app, although I can’t figure out what could be causing it.