ITK Python pyinstaller issue

You can try to use a hook file with this content:

# This pyinstaller hook file does not support ITK with `WrapITK.pth`.

from PyInstaller.utils.hooks import collect_data_files

hiddenimports = ['new']

# If ITK is pip installed, gets all the files.
itk_datas = collect_data_files('itk', include_py_files=True)
datas = [x for x in itk_datas if '__pycache__' not in x[0]]

Save the code above in a file called hook-itk.py and add --additional-hooks-dir= to the command line calling pyinstaller, with the name of the folder in which you saved hook-itk.py.

If this works for you, I will ask pyinstaller if they can ship this hook file directly in their project.
Thanks!

2 Likes