Search code examples
pyinstallerpytables

Add collect PyTables library to PyInstaller SPEC File


I am using PyInstaller to build an executable of a python script containing PyTables. Since I've updated to the newest version, building the executable fails. The error reads:

Error: RuntimeError: Blosc2 library not found. I looked for "libblosc2.dll, C:\Users\USER\AppData\Local\Temp_MEI10642\tables\libblosc2.dll, None"

According to this post, adding tables binary is now needed: https://github.com/pyinstaller/pyinstaller/issues/7408

I have a SPEC-File and dont know how to add the missing library. I've tried the following:

So I am trying to add

Case 1:

binaries=[('C:\\Python39\\bin\\libblosc2.dll', 'BINARY')]

Error:

RuntimeError: Blosc2 library not found. I looked for "libblosc2.dll, C:\Users\USER\AppData\Local\Temp\_MEI10642\tables\libblosc2.dll, None"

Case 2:

binaries=[('C:\\Python39\\bin\\libblosc2.dll', '.')]

The loader hangs in a loop and not starting the executable.

So, how do I add the "Just add --collect-binaries=tables to your pyinstaller command" properly to my SPEC-File?

Thanks!

System-Info: INFO: PyInstaller: 6.3.0 INFO: Python: 3.9.7 INFO: Platform: Windows-10-10.0.19044-SP0 INFO: tables 3.9.2


Solution

  • I also have the same problem. --collect-binaries=tables only works for command line. To resolve this issue, you can add the following to your app.spec file:

    from PyInstaller.utils.hooks import collect_dynamic_libs
    
    binaries = []
    binaries += collect_dynamic_libs('tables')
    
    a = Analysis(
        ...
        binaries=binaries,
        ...
    )
    

    If you encountered loader stuck in loop after successfully building the app, you can see the following issue Loader stuck in loop with PyTables