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.
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.
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!
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