Closed charmeem closed 2 years ago
This issue is resolved after upgrading dash to 2.5 and following suggestions in earlier issue#112
However Now I am getting ' Duplicate callback Outputs' for every callback although there is no duplicate Output exits.
In the callback for output(s):
histograms-graph.figure
Output 0 (histograms-graph.figure) is already in use.
Any given output can only have one callback that sets it.
To resolve this situation, try combining these into
one callback function, distinguishing the trigger
by using `dash.callback_context` if necessary.
from dash import Dash, dcc, html, Input, Output, callback
from dash import register_page
import plotly.express as px
import numpy as np
register_page(__name__)
np.random.seed(2020)
layout = html.Div(
[
dcc.Graph(id="istograms-graph"),
html.P("Mean:"),
dcc.Slider(
id="histograms-mean", min=-3, max=3, value=0, marks={-3: "-3", 3: "3"}
),
html.P("Standard Deviation:"),
dcc.Slider(id="histograms-std", min=1, max=3, value=1, marks={1: "1", 3: "3"}),
]
)
@callback(
Output("histograms-graph", "figure"),
Input("histograms-mean", "value"),
Input("histograms-std", "value"),
)
def display_color(mean, std):
data = np.random.normal(mean, std, size=500)
fig = px.histogram(data, nbins=30, range_x=[-10, 10])
return fig
import dash
import dash_bootstrap_components as dbc
app = dash.Dash(
__name__, use_pages=True, external_stylesheets=[dbc.themes.BOOTSTRAP]
)
navbar = dbc.NavbarSimple(
dbc.DropdownMenu(
[
dbc.DropdownMenuItem(page["name"], href=page["path"])
for page in dash.page_registry.values()
if page["module"] != "pages.not_found_404"
],
nav=True,
label="More Pages",
),
brand="Multi Page App Plugin Demo",
color="primary",
dark=True,
className="mb-2",
)
app.layout = dbc.Container(
[navbar, dash.page_container],
fluid=True,
)
if __name__ == "__main__":
app.run_server(debug=True)
HI @charmeem Are you on Windows? If so, this is a bug and will be fixed in 2.5.1. The new release with the patch is coming soon.
Yes I am using Windows. Will wait for the new release, thanks.
Hi @charmeem 5.1 was just released :confetti_ball:
Could you try running these multi-page sample apps and let me know how it goes?: https://github.com/AnnMarieW/dash-multi-page-app-demos
Hello, I have just tried after upgrading to 2.5.1 , still seeing the same errors however with one improvement. I can see the pages in the navigation bar which was not the case before.
Exception Exception: modules ['pages..ipynb_checkpoints.heatmaps-checkpoint', 'pages.heatmaps'] have duplicate paths
Traceback (most recent call last) File "C:\Users\hp\anaconda3\Lib\site-packages\flask\app.py", line 2464, in call return self.wsgi_app(environ, start_response) File "C:\Users\hp\anaconda3\Lib\site-packages\flask\app.py", line 2450, in wsgi_app response = self.handle_exception(e) File "C:\Users\hp\anaconda3\Lib\site-packages\flask\app.py", line 1867, in handle_exception reraise(exc_type, exc_value, tb) File "C:\Users\hp\anaconda3\Lib\site-packages\flask_compat.py", line 39, in reraise raise value File "C:\Users\hp\anaconda3\Lib\site-packages\flask\app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "C:\Users\hp\anaconda3\Lib\site-packages\flask\app.py", line 1945, in full_dispatch_request self.try_trigger_before_first_request_functions() File "C:\Users\hp\anaconda3\Lib\site-packages\flask\app.py", line 1993, in try_trigger_before_first_request_functions func() File "C:\Users\hp\anaconda3\Lib\site-packages\dash\dash.py", line 2268, in router _validate.check_for_duplicate_pathnames(_pages.PAGE_REGISTRY) File "C:\Users\hp\anaconda3\Lib\site-packages\dash_validate.py", line 435, in check_for_duplicate_pathnames raise Exception(f"modules {modules} have duplicate paths")
:thinking: So, you see these errors when you run one of the apps from the github repo I shared the link to previously?
can you share the code you are running? It looks like there might be conflicts between "Histogram" and "Histogram-checkpoint" for example
wait
Yes I am running codes in multi_page_example_1
import dash
import dash_bootstrap_components as dbc
app = dash.Dash(
__name__, use_pages=True, external_stylesheets=[dbc.themes.BOOTSTRAP]
)
navbar = dbc.NavbarSimple(
dbc.DropdownMenu(
[
dbc.DropdownMenuItem(page["name"], href=page["path"])
for page in dash.page_registry.values()
if page["module"] != "pages.not_found_404"
],
nav=True,
label="More Pages",
),
brand="Multi Page App Plugin Demo",
color="primary",
dark=True,
className="mb-2",
)
app.layout = dbc.Container(
[navbar, dash.page_container],
fluid=True,
)
if __name__ == "__main__":
app.run_server(debug=True)
This looks odd:
Exception: modules ['pages..ipynb_checkpoints.heatmaps-checkpoint', 'pages.heatmaps'] have duplicate paths
Do you know where 'pages..ipynb_checkpoints.heatmaps-checkpoint
might be coming from?
from dash import Dash, dcc, html, Input, Output, callback
from dash import register_page
import plotly.express as px
import numpy as np
register_page(__name__)
np.random.seed(2020)
layout = html.Div(
[
html.P("Mean:"),
dcc.Slider(
id="histograms-mean", min=-3, max=3, value=0, marks={-3: "-3", 3: "3"}
),
html.P("Standard Deviation:"),
dcc.Slider(id="histograms-std", min=1, max=3, value=1, marks={1: "1", 3: "3"}),
dcc.Graph(id="histograms-graph"),
]
)
@callback(
Output("histograms-graph", "figure"),
Input("histograms-mean", "value"),
Input("histograms-std", "value")
)
def display_color(mean, std):
data = np.random.normal(mean, std, size=500)
fig = px.histogram(data, nbins=30, range_x=[-10, 10])
return fig
It is now working. ipynb_checkpoints was the directory automaticaly created by Jupyter note book. After removing that the code is wording fine.
Let me test with heatmaps.py page as well.
All working now, Thanks for your hints.
oh, great - thanks! Now we'll know what to do for the next person who might have a similar issue :+1:
Can I close the case?
yes, please
OK, appreciate the work you are doing designing this wonderful product, keep it up !
Hi. Please am trying to deploy my link to render. But am getting errors: dash.exceptions.NoLayoutException: The layout was None
at the time that run_server
was called. Make sure to set the layout
attribute of your application before running the server
Hi @Damistar05 - If you can post your code and your question on https://community.plotly.com/ there are lots of folks who will be happy to help!
Hi @Damistar05 - please don't use this version - this was a prototype used to develop the Dash Pages feature and is no longer being maintained. This feature is now part of Dash :-)
When trying to run the demo code of Chapter08-MultiPageDashApp I am getting this error. This error however doesn't generates if I include only histogram.py file in /pages folder. As I add other files like bar_charts.py this error appears.
Detail print out: