Dash[diskcache]

This is installed but still I am getting this error:

dash.exceptions.MissingLongCallbackManagerError: Running long callbacks requires a manager to be installed.
Available managers:

  • Diskcache (pip install dash[diskcache]) to run callbacks in a separate Process and store results on the local filesystem.
  • Celery (pip install dash[celery]) to run callbacks in a celery worker and store results on redis.

What does your import and initialization of the app look like?

from datetime import datetime as dt
import time
import os
import dash
import dash_bootstrap_components as dbc
from dash import html, dcc, DiskcacheManager, CeleryManager, callback
from dash.dependencies import Input, Output, State
import plotly.graph_objects as go
import plotly.express as px
import yfinance as yf

if 'REDIS_URL' in os.environ:
    # Use Redis & Celery if REDIS_URL set as an env variable
    from celery import Celery
    celery_app = Celery(__name__, broker=os.environ['REDIS_URL'], backend=os.environ['REDIS_URL'])
    background_callback_manager = CeleryManager(celery_app)

else:
    # Diskcache for non-production apps when developing locally
    import diskcache
    cache = diskcache.Cache("./cache")
    background_callback_manager = DiskcacheManager(cache)

For me, I needed to add this to the app initializing:

app = dash.Dash(__name__, background_callback_manager=background_callback_manager)
1 Like

aha, great, i have a multiple page app, when I added these line to to the app.py it worked, thank you

1 Like

Hi! This is likely a “duh!” question, but: Where is dash[diskcache] stored? I cannot find it in pypi. I cannot seem to find it in github either. Thanks!

ImportError: DiskcacheLongCallbackManager requires extra dependencies which can be installed doing

    $ pip install "dash[diskcache]"

Alternatively, can these “extra dependencies” be installed manually?

EDIT: This was indeed a “duh!” question. The extra dependencies can be found here:

https://github.com/plotly/dash/blob/dev/requires-diskcache.txt

They are: multiprocess, diskcache and psutil. Installing them mannualy solves the issue.

Thanks!

1 Like