*** UPDATE ***
While my answer below might work, it’s not the right way. Please see the correct solution in this post:
Original answer -(don’t do it this way - see above)
I haven’t tried making an exe file from a pages app, but here is how you can make it so dash does not look for the pages folder. Basically, you do this by registering each page in app.py instead of from within the pages folder.
Note - this will only work ind dash>=2.5.1
Assuming you have a project structure that looks like this:
- app.py
- pages
|-page1
|-page2
-
Remove
dash.register_page(__name__)frompages.page1andpages.page2 -
Then in app.py, import each page:
from pages import page1, page2
- Register the page in
app.py. You will have to assign the layout and give each a unique module name rather than using__name__,
dash.register_page("page1", path="/", layout=page1.layout)
dash.register_page("page2, layout=page2.layout)
- Set the name of the pages folder to
""
app = dash.Dash(__name__, use_pages=True, pages_folder="")
Please let me know if this works for you and it’s possible to create an exe file.