..Error Loading Layout

earlier my dashboard was working fine. Then i added some callbacks and it started showing ‘error loading layout’. To check , i removed my callback code and tried running it again . To my surprise , even my previous code (which was working fine earlier) stared giving ‘‘error loading layout’’ message . I am ruuning it on Jupyter. This is my code without callback:

‘’’
app = JupyterDash(name, external_stylesheets=[dbc.themes.BOOTSTRAP])
dropdown_list = {‘Sectoral Indices’: sectors_df, ‘F&O Stocks’: fno_df, ‘Nifty 50’: nifty50_df, ‘Bank Nifty’:banknifty_df}
time_frames = [“Daily”, ‘Weekly’, “Monthly”, ‘Quarterly’]
advances = “x”
decline = “y”

adv_dec_card = dbc.Card(dbc.CardBody([
html.H4(“Advances / Decline”, className = “card-title”),
html.P(
f"{advances} / {decline}", className = “card-text”
)
]
), style = {“width”: “18rem”, “text-align”:“center”}
)

#def layout():

app.layout = html.Div([
html.H1(children=“Dashboard”),
html.Hr(),
dbc.Row(
dbc.Col(html.Div(dcc.Dropdown(id=‘dropdown’, options = dropdown_list, value=‘Nifty 50’, )), width=3
)),
html.Br(),
html.Br(),
dcc.RadioItems(time_frames, “Daily”, labelStyle={‘display’: ‘block’}),
html.Br(),
html.Br(),
adv_dec_card,
html.Br(),
html.Img(src = ‘https://www.tetonpinesfinancial.com/wp-content/uploads/2016/01/Bulls-vs.-Bears.jpg’,
height = 150, width=300),
],

    style={'padding': 15, 'flex': 1}
                )

if name == “main”:
app.run_server()
‘’’

Kindly help . I have to submit my assignment .

It’s working for me with some revise as below:

import dash
from dash import Dash, Input, Output, html, dcc
import dash_bootstrap_components as dbc

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
dropdown_list = {'Sectoral Indices': 'Sectoral Indices', 'F&O Stocks': 'F&O Stocks', 'Nifty 50': 'Nifty 50', 'Bank Nifty':'Bank Nifty'}
time_frames = ["Daily", 'Weekly', "Monthly", 'Quarterly']
advances = "x"
decline = "y"

adv_dec_card = dbc.Card(dbc.CardBody([
html.H4("Advances / Decline", className = "card-title"),
html.P(
f"{advances} / {decline}", className = "card-text"
)
]
), style = {"width": "18rem", "text-align":"center"}
)

#def layout():

app.layout = html.Div([
html.H1(children="Dashboard"),
html.Hr(),
dbc.Row(
dbc.Col(html.Div(dcc.Dropdown(id='dropdown', options = dropdown_list, value='Nifty 50', )), width=3
)),
html.Br(),
html.Br(),
dcc.RadioItems(time_frames, "Daily", labelStyle={'display': 'block'}),
html.Br(),
html.Br(),
adv_dec_card,
html.Br(),
html.Img(src = 'https://www.tetonpinesfinancial.com/wp-content/uploads/2016/01/Bulls-vs.-Bears.jpg',
height = 150, width=300),
],

    style={'padding': 15, 'flex': 1}
                )
if __name__ == '__main__':
    app.run(debug=False, port=1718)

Can you post your code with callback and data?

Its still showing the same error to me . As far as can check , you have just added ‘‘debug = False, port=1718’’. right?

1 Like

Yep, if you are using Jupyternotebook, you should add debug = False

i have it False only

yesterday the same code was working fine

Hm try to change your default port and see if it worked. Another note: I don’t have your df so I changed dropdown setting.

Hey thanks. It worked. But funny enough , though our code was same , the one written by me didn’t work . So i deleted my code and pasted the code you sent . and it worked.

1 Like