4

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?

  • Is it the same if I change the mode to `inline`? Are the jupyterlab and dash related modules up to date? – r-beginners Jan 30 '22 at 02:49
  • I am seeing the same problem on Google Colab with code that was working a few weeks back and unchanged. My guess is its to do with the new release of jupyter-dash 0.4.0 but could not pin point/fix. – prav Jan 30 '22 at 03:07
  • "Is it the same if I change the mode to inline" yes, i tried inline as well as debug=True and debug=False, everythin with the same negative result :( My jupyterlab and jupyter notebook are up to date and the same goes to jupyter_dash (installed via yesterday) ;/ – Damian Szarik Paul Jan 30 '22 at 19:21

5 Answers5

3

I had the same problem today. Please downgrade your dash to 2.0.0, and it will work
pip install dash==2.0.0

  • Hi, a friend of mine tried downgrade dash to 2.0.0 it helped him, but it didn't help another one. What is more, my conda refuses obedience to check it out. I found sbb answer actually works, it's not strictly JupyterDash but dash, anyway it solves my problem :)) Thanks for respond! – Damian Szarik Paul Jan 31 '22 at 13:34
2

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!

sbb
  • 21
  • 1
  • Hi! Thanks, it's not exaclly what i meant, I wanted to actually use JupyterDash, not Dash but still it solves my problem, i can do the same with this Dash actually ;P – Damian Szarik Paul Jan 31 '22 at 13:35
  • I must say that another error occured, i couldn't close local host no matter what, execution ctrl + c doesnt work in jupyter notebok nor i n jupyter lab so i could only restart kernel. But when i do that, all data is lost and i have to compile it all over again each time. I downgraded version to 1.19.0 like above in post and it worked like a cure :) – Damian Szarik Paul Jan 31 '22 at 14:18
2

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.

Screenshot

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")
Abhishek V
  • 87
  • 2
  • Hi, a friend of mine tried downgrade dash to 2.0.0 it helped him, but it didn't help another one. What is more, my conda refuses obedience to check it out. I found sbb answer actually works, it's not strictly JupyterDash but dash, anyway it solves my problem :)) Thanks for respond! – Damian Szarik Paul Jan 31 '22 at 13:33
1

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.

  • Hi, a friend of mine tried downgrade dash to 2.0.0 it helped him, but it didn't help another one. What is more, my conda refuses obedience to check it out. I found sbb answer actually works, it's not strictly JupyterDash but dash, anyway it solves my problem :)) Thanks for respond! – Damian Szarik Paul Jan 31 '22 at 13:33
0

You could also try setting the host:

app.run_server(host="127.0.0.1", port="8050")
Sunday Ikpe
  • 924
  • 10
  • 17