Page not found for Multipage app when running the code as a module

Dash version 2.2.0 and dash-labs is installed

I am creating a multipage app with the latest dash version and trying to execute the scripts as python package. I get an error of page not found even when the pages folder exists with the relevant .py files. However, when I run the file ( as a script (from Pycharm’s Run button option in the IDE), the app works fine.

I am using the example from Adams github repo: Dash-by-Plotly/Dash_More_Advanced_Shit/Multipage_app at master · Coding-with-Adam/Dash-by-Plotly · GitHub

The folder hierarchy is:

│   ├───folder2
│   │   └───pages
│   │   

And I run the script as python -m

Is there anything extra step to run the script as a module?

Note: I was already using dash all this time and running it as a module which worked fine. Now, I want to upgrade the app to multipage app.


Did you try moving into “folder2” and running the app from there?

Yes, moving into folder2 and then executing the code as a module works!

However, in my original project, I need to run my code from the root directory (which is equivalent to folder1 having several sub-folders). There would be problem in calling other modules if I move to the folder containing for execution.

Any solution regarding how can I execute the script from folder1?

I think that your issue can be considered as a bug in the pages plugin. What do you say, @AnnMarieW ? :slight_smile:

1 Like

I believe you can work around the issue by adding the following snippet at the top of,

import os

I get ModuleNotFoundError as follows:

File “D:\ …\lib\site-packages\dash_labs\plugins\”, line 292, in _import_layouts_from_pages
page_module = importlib.import_module(f"pages.{page_filename}")


At the same time, I would like to point out that in Pycharm, I register_page and page_registry are not found as shown below from the editor snip. Note that still the program runs successfully (of course executed as a script or as a module from the same path). Any information on this?



Hi @hundredmiles and @Emil

Yes, this is a bug in the pages plugin. I fixed it in the pull request to add\pages to dash, but it looks like it may be a while until that PR is reviewed. I’ll do a PR to fix it in dash-labs as well.

1 Like

Thanks @AnnMarieW for the information. Will wait for the fix. Also, thanks @Emil for your insights.