Reputation: 99
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?
Upvotes: 4
Views: 9103
Reputation: 974
You could also try setting the host:
app.run_server(host="127.0.0.1", port="8050")
Upvotes: 0
Reputation: 87
The following piece of code helped me obtain an output, I hope it works for you too. It appears that the recent changes in Jupyter_dash are responsible for the breakage in functionality, I could be wrong though.
I am a newbie and your feedback if the code worked or didn't helps me learn too. I have attached a screenshot of the output I obtained using Google Colab.
Thanks in advance.
Please try this:
#Installing specific packages.
!pip install -q dash==1.19.0
!pip install -q jupyter_dash==0.3.0
#Importing the libraries.
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")
Upvotes: 2
Reputation: 11
For the ones having trouble in Google Colab notebooks, I have tested Jeffin Jacob's statement pip install dash==2.0.0
and it worked.
It seems that now installing jupyter-dash
in colab notebooks automatically installs dash 2.1.0 dependency instead of dash 2.0.0 that actually works.
I hope this info could help you.
Upvotes: 1
Reputation: 35
I had the same problem today. Please downgrade your dash to 2.0.0, and it will work
pip install dash==2.0.0
Upvotes: 3
Reputation: 31
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!
Upvotes: 3