How to build exe file of multipage dash app

Hi,

I am having an issue with multipages in dash, pages not showing when I bundle my app into a .exe or .msi package. The error being the pages folder could not be found. But when I run the app.py directly it works perfectly.

Is there any specific parameters I shall add to the app.py or setup.py to make it work ?

Kind regards,

Hi! I’m actually quite interested in how you do this. Which package are you using? - It is also hard to debug your specific problem without knowing this detail. From my experience with similar tools, I suspect that there is a configuration that you have to make so that the pages folder is correctly bundled with your other code.

It would also be great to know the folder structure of your current app and the folder structure so that the bundling works.

Hi,
Thanks for prompt reply. The bundling of the app only works is just when I try to include multipages that I cannot view them.

The folder structure is the following
app.py
server.py
setup.py
requirements.txt
pages
homepage.py
init.py

I am running the command: python setup.py bdist_msi where the setup.py resides

setup.py is as follow:

“”"
from setuptools import find_packages
from cx_Freeze import setup, Executable

options = {
‘build_exe’: {
‘includes’: [
‘cx_Logging’, ‘idna’,
],
‘packages’: [
‘asyncio’, ‘flask’, ‘jinja2’, ‘dash’, ‘plotly’, ‘waitress’, ‘pages.vessel_motions_extraction’
]
}
}

executables = [
Executable(‘server.py’,
base=‘Win32GUI’,
target_name=‘MY_APP.exe’)
]

setup(
name=‘MY_APP’,
packages=find_packages(),
version=‘0.0.1’,
description=‘Demo App’,
executables=executables,
options=options
“”"

error when running the .exe file:

Hi @andrereisantunes and welcome to the dash community.

Could you please try to make an exe file from one of the example apps in this project? Then it would be easier to see if this is an issue with dash or if there is something in how your project is set up.

Hi Ann,

Thanks for suggestion. I’ve tested with your example and just added the setup.py as per below. Did not work either.

Oh, I think this has come up before, and it may not be possible to use the pages folder when building an exe file. However, it is possible to use the multi-page app features without using the pages folder. You can find instructions on how to do that here

Before making your app run without the pages folder, you could try making an executable file from this example app

Hi @andrereisantunes,

To solve this, you simply need to include 'include_files': ['pages/'] into the build_exe option dict. For your example, here’s working code.

from setuptools import find_packages
from cx_Freeze import setup, Executable

options = {
    'build_exe': {
        'include_files': ['pages/'],
        'includes': [
            'cx_Logging', 'idna'
        ],
        'packages': [
            'asyncio', 'flask', 'jinja', 'dash', 'plotly', 'waitress'
        ]
    }
}

executables = [
    Executable(
        'app.py',
        base='console',
        targetName='app_executable.exe'
    )
]

setup(
    name='TEST_APP',
    packages=find_packages(),
    version='0.0.1',
    description='app_executable',
    executables=executables,
    options=options,
)


1 Like

@3d65 Thanks so much for your answer! :rocket:

1 Like

Thank you so much 3d65. That solved the problem :smiley:

2 Likes

Thank you for the answer, this solution also pointed me in the right direction. However, unfortunately I am still struggling with the pages. Although it now has stopped throwing the original error, it gives a 404 Page not Found error… So somehow it still is not finding the pages on runtime. Anything I can do?

EDIT:

Important note is that the non-page-based elements of the page are working just fine, such as the sidebar etc.