Multipage app demo broken

I’m running the demo from https://plot.ly/dash/urls (bottom part of the page “Structuring a Multi-Page App”) and notice that the following code from app1.py is not executing when I change the dropdown value.

@app.callback(
    Output('app-1-display-value', 'children'),
    [Input('app-1-dropdown', 'value')])
def display_value(value):
    return 'You have selected "{}"'.format(value)

When I move the method from app1.py into index.py it runs fine.

Not sure what the problem is as I’m using the sample code with no change.

I’m using:

dash==0.19.0
dash-core-components==0.15.0rc1
dash-html-components==0.8.0
dash-renderer==0.11.1

I found a workaround to the problem. Think this a dash bug that doesn’t find all @app.callback functions when importing the dash app object from a fully qualified python path.

While loading the demo files into my IDE (eclipse or pycharm), app1.py and app2.py were complaining while importing app. I therefore changed the imports to fully qualified python paths. After this, dash was not finding the callbacks embedded within app1 and app2. Reverting back to the demo imports solved this.

This is my project structure:

dash_test
   |- multi_app
   |      |- apps
   |      |      |- app1.py
   |      |      |- app2.py
   |      |- app.py
   |      |- index.py

This was my import in app1.py and app2.py so the IDE wouldn’t complain:

from dash_test.multi_app.app import app

instead of the one from the demo file:

from app import app

Thanks for reporting @bkelemen! Oddly, the app structure in the docs works for me (in both python2 and 3).

Where are you calling this function? The intended usage is that you call it inside the multi_app folder:

$ ls 
app.py 
apps
index.py

$ python index.py
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)

I can’t get it to work either, it returns a 404 even though I changed the else: from ‘404’ to “You’re lost”. I spent most the day trying to get my original projects ported over to a multipage app and now I’m thinking something else is going on. I recently updated the libraries, perhaps I should revert to the ones listed on the example page?

edit: I realized I had a server running (from a poorly killed attempt) that was blocking the port, I found the process killed it and now everything works fine. Even my own app!

1 Like

Hi Chris,

This is weirded. I can only reproduce the issue from within the IDE when running index.py. I believe this has something to do with the PYTHONPATH the IDE is setting. As this is not blocking me anymore, I wouldn’t spend too much time on it.

Just for refrerence for the future, this is what I did: I left app2.py as-is and modified app1.py only by replacing:

from app import app

with

from multi_app.app import app

This makes the IDE happy in app1.py while still highlighting a compile error in the import of app2.py. When running the app no error is displayed in the console, but the callback in app1 is not being executed (and therefore the text “You have selected …” doesn’t appear). This continues to work fine in app2 with the original untouched import.

Also, when running this demo from the command prompt I get this error:

$ python index.py
Traceback (most recent call last):
  File "index.py", line 7, in <module>
    from apps import app1, app2
  File "/Users/XXXXXX/Python Workspace/dash_test/multi_app/apps/app1.py", line 5, in <module>
    from multi_app.app import app
ImportError: No module named multi_app.app

you have to append “/apps/app1” to the url http://127.0.0.1:8050 to get it to run

http://127.0.0.1:8050/apps/app1