PyInstaller error when executing Plotly Dash .exec file

I am trying to create a .exe file to run a python dashboard created with Plotly Dash. Once I create the file with PyInstaller and try to run it, I get this error:

Traceback (most recent call last):
  File "app.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "/Users/mohamedmartino/opt/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages/dash_core_components/__init__.py", line 12, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/np/m30g9mj57h72n68qxc2tq61m0000gn/T/_MEI2yKNs4/dash_core_components/package-info.json'
[85571] Failed to execute script app

I’m new to coding, and I can’t figure out why it can’t find the dcc dependency. Is there a better way to compile my modules into one executable file?

I have a few python modules and excel files in the same directory as well as an -asset folder with images and css files.

Hi @mmartino, did you take a look at this previous discussion Convert Dash to executable file (.exe) ? Maybe it can help.

1 Like

Did you manage to create the exe file with PyInstaller? I’m going to be done my app in a couple months and the thought of not being able to make an exe file scares the life out of me. If you did succeed, does the browser open by itself on execution of the file? or do you have to manually navigate to a specific location. Thx

Unfortunately, I was not able to turn this into an executable app. To create my reports, I just run my code through the terminal. If you’re able to make this executable for any user, I’d be interested in learning how you did it.

@mmartino follow the discussion at Convert Dash to executable file (.exe) as @Emmanuelle mentioned.

I managed to create an executable dash app following Philippe’s answer.

How can one manage to create and .exe file when you have multiple .py files that you import into your app.py file and a data anf assets folder?

Would you mind sharing the versions of Python/packages that you’ve used? I’m trying to follow his answer, but have a problem with the cx_Logging module.

I also have a problem with the cx_Logging module. Curious to know if you’ve figured it out

You may try to add the path of the dash_core_components to the .spec file, and use the .spec file to pyinstaller
like the following example:

a = Analysis(['runme.py'],
             pathex=['D:\\myDash'],
             binaries=[],
             datas=[
                 ('D:\myDash\main_dash\package_venv\Lib\site-packages\dash_html_components','dash_html_components'),
                 ('D:\myDash\main_dash\package_venv\Lib\site-packages\dash_core_components','dash_core_components'),
                 ('D:\myDash\main_dash\package_venv\Lib\site-packages\dash_bootstrap_components','dash_bootstrap_components'),
                 ('D:\myDash\main_dash\package_venv\Lib\site-packages\dash_renderer','dash_renderer'),
                 ('D:\myDash\main_dash\package_venv\Lib\site-packages\dash_table','dash_table')  
             ],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)