luca pescatore
luca pescatore

Reputation: 119

Dask + pyinstaller fails

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?

Upvotes: 6

Views: 3373

Answers (2)

Sajjad Aemmi
Sajjad Aemmi

Reputation: 2605

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.

Upvotes: 0

Masoud Rahimi
Masoud Rahimi

Reputation: 6031

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

Upvotes: 7

Related Questions