Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Dash multipage app server issue - dash.exceptions.NoLayoutException

Following guidelines to structure a multipage dash app here: URL Routing and Multiple Apps | Dash for Python Documentation | Plotly

Trying to replicate and adjust following the example in the link, adding one layer on top for execution.

It works fine if I go in the multipageapp folder and execute the file from there. However, I am getting the following error when executing the file, I am not sure what I am doing wrong, it seems like it match what’s in the example.

Following link contains the exact code I am using:

It looks like the issue is that when you run the file, you are not setting the layout of the app with app.layout = something. That is why you are getting a NoLayoutException .

I would move your layout to its own variable, try importing it into, and then assign it to the app there:

layout_div = html.Div([
    dcc.Location(id='url', refresh=False),
app.layout = layout_div

The layout is defined in as in the example used in the Dash documentation.

They do mention the following at the end of the page:
" It is worth noting that in both of these project structures, the Dash instance is defined in a separate , while the entry point for running the app is . This separation is required to avoid circular imports: the files containing the callback definitions require access to the Dash app instance however if this were imported from , the initial loading of would ultimately require itself to be already imported, which cannot be satisfied."

Hence why layout is separated from server, your solution would go against the recommended way of structuring multipage app I believe.

What I really want to get to is: using their recommended solution, how can I run the app from a file located in the parent folder of the structure they describe? (I need to do so for my specific corporate deployment)

I tried your proposed solution, but now get an error due to this circular reference


Traceback (most recent call last):
File “”, line 6, in
from multipageapp.index import layout_app
File “\multipageapp\”, line 5, in
from app import app
ModuleNotFoundError: No module named ‘app’

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

from app import app
from apps import app1, app2

layout_app = html.Div([
dcc.Location(id=‘url’, refresh=False),

@app.callback(Output(‘page-content’, ‘children’),
[Input(‘url’, ‘pathname’)])
def display_page(pathname):
if pathname == ‘/apps/app1’:
return app1.layout
elif pathname == ‘/apps/app2’:
return app2.layout
return ‘404’

if name == ‘main’:

from import app, server
from multipageapp.index import layout_app

app.layout = layout_app

if name == “main”:, port=8050)

I’m curious about what your intention in using was in the first place. It seems like an extra layer around the file which was working fine on its own, according to your 1st post.

This has to do with doing a deployment of the app on AWS - this constraint of an overarching file come from my I.T. department.

Found out a way to make it work. I simply moved the content of ‘’ into ‘’, deleted ‘’ and I adjusted the imports to have folder ‘multipageapp’ inside

1 Like

That’s excellent!

I was assuming that you wanted to keep and together, but knowing you only need one definitely means you could just import all the content of over to one file (running server, etc).

I wanted to - in order to keep organization of code as in dash example, but I gave up as I could not find a way to do so. Thanks for your help anyway