Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JupyterDash app.run_server error using Jupyter Notebook

I am trying to make charts using JupyterDash but first things first... i can't run simple JupyterDash test via Jupyter Notebook because every time i receive the same error:

AttributeError: ('Read-only: can only be set in the Dash constructor or during init_app()', 'requests_pathname_prefix')

My code:

from jupyter_dash import JupyterDash
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objs as go
import plotly.express as px
import dash
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = JupyterDash(__name__,external_stylesheets = external_stylesheets) #

app.layout= html.Div([html.H1("Hello world!!!"),
                  html.Div("This is the first paragraph"),
                 html.H1("Welcome back"),
                 html.Div("This is the second paragraph"),
                  html.Div(id="no_show",style= {'display':'none'}),
                 dcc.Graph(id = "graph",figure = go.Figure())],
                style = {"text-align":"center"})

app.css.config.serve_locally = True
app.scripts.config.serve_locally = True

if __name__ =='__main__':
    app.run_server(mode="external") #debug=True

I tried many different variations of app.run_serwer(....) and none works. Also tried to run this sample in JupyterLab with the same negative result. I have installed JupyterDash via:

pip install jupyter-dash

Any suggestions how to solve this problem?

like image 580
Damian Szarik Paul Avatar asked Sep 14 '25 13:09

Damian Szarik Paul


1 Answers

I had the same problem with and old notebook, after some changes, it works again.

Initially, I had the code below:

app = JupyterDash(__name__)
app.run_server(mode=external,port=8050)

I have changed them by this:

app=dash.Dash(__name__)
app.run_server()

I hope these changes could help you!

like image 70
sbb Avatar answered Sep 17 '25 03:09

sbb