6

I am trying to use dask dataframes into a packaged executable using pyinstaller.

I have just

import dask

in my executable and I package it with

pyinstaller scripts.py

When I run it I get that /some/path/dask.yaml is not found.

Does somebody know if there are hidden imports that I should add or how else to solve this issue?

Safak Ozdek
  • 906
  • 11
  • 18
luca pescatore
  • 119
  • 1
  • 8

2 Answers2

6

For using dask with PyInstaller you need to add dask.yaml and distributed.yaml to your output executable with add-data flag:

pyinstaller -F --add-data "<python_path>/Lib/site-packages/dask/dask.yaml;./dask" --add-data "<python_path>/Lib/site-packages/distributed/distributed.yaml;./distributed" script.py
Masoud Rahimi
  • 5,785
  • 15
  • 39
  • 67
  • This is a bit sad really, isn't it? There could be any number of miscellaneous files in your dependencies that you don't notice aren't included until you hit a particular code path? – UtterlyConfused Jan 23 '20 at 11:23
  • @UtterlyConfused Some Python modules don't build with the only Python and they may have other dependencies. But I think it is not a big deal to provide them manually. – Masoud Rahimi Jan 23 '20 at 13:52
  • 1
    I created a bug report for this issue https://github.com/dask/dask/issues/6634 – Korijn Sep 14 '20 at 08:30
  • @Korijn I think this is not a Dask problem. It would be better to report it on [PyInstaller](https://github.com/pyinstaller/pyinstaller/issues). – Masoud Rahimi Sep 14 '20 at 09:19
0

If dask is installed in <python_path>\Lib\site-packages\theano, you need to create a hook-dask.py file with this content:

from PyInstaller.utils.hooks import get_package_paths
datas = [(get_package_paths('dask')[1],"dask"),]

and copy this file into your PyInstaller folder:

Lib\site-packages\PyInstaller\hooks

When you run pyinstaller, you need to add the path of site-packages with the -p option:

pyinstaller myApp.py -p <python_path>\Lib\site-packages

It will copy the entire dask folder into your dist output folder.

Sajjad Aemmi
  • 2,120
  • 3
  • 13
  • 25