I have some updates!
-
Running cx_Freeze from a virtual environment works! It creates a much smaller folder/executable as it only brings the packages you installed in the virtualenv. HOWEVER, cx_Freeze has a bug that prevents it to work with virtualenv out of the box with some packages. Fortunately, there is a workaround here: https://stackoverflow.com/questions/14247130/cxfreeze-missing-distutils-module-inside-virtualenv
-
your executable will not be able to access your local CSS/JS/Favicon that you put in the
assets/folder. In order to fix this, you need to create your dash app asapp = dash.Dash(__name__, assets_folder=find_data_file('assets/'))wherefind_data_fileis defined as
def find_data_file(filename):
if getattr(sys, 'frozen', False):
# The application is frozen
datadir = os.path.dirname(sys.executable)
else:
# The application is not frozen
# Change this bit to match where you store your data files:
datadir = os.path.dirname(__file__)
return os.path.join(datadir, filename)
On top of that, you need to include the assets/ folder in your setup.py script under includefiles
You can use the above function to read data files as well, as long as you passed them in the setup.py files.
Hope this helps anyone in the future who wants to create Dash ‘double click’ apps!