Host dash apps in the browser using PyCafe

I try to upload an app which uses dash_daq but whatever I try, I get this message:

Error in dash app:
Traceback (most recent call last):

File “/lib/python3.12/jc/dash.py”, line 110, in load_app
import app as main_module

File “/home/pyodide/project-files/app.py”, line 16, in
import dash_daq as daq

File “/lib/python3.12/site-packages/dash_daq/init.py”, line 14, in
_components = _dash.development.component_loader.load_components(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: module ‘dash.development’ has no attribute ‘component_loader’

dash_daq is in the requirements, I tried the app with dash_daq 0.5.0 and 0.6.0, works both.

Does somebody have an idea how to fix this? The code is here:

Hey @marieanne - I don’t have a specific solution for this error message, but I do have a suggestion that might help you avoid it altogether: Instead of using daq.ToggleSwitch, you could switch to dbc.Switch. That way, you can eliminate the need for the dash-daq dependency entirely. Would that work?

dbc.Switch(
           id="mode-switch",
           label=["Emigration", "Immigration"],
           value=True # False = Origin, True = Destination,
       )
3 Likes

Perfect thank you @li.nguyen! There is some adjusting to do but it works. You must be a mind reader I was looking for an alternative a few hours ago :folded_hands:

1 Like