Unhandled exception using tabula (read_pdf) in built .exe

44 Views Asked by At

Example code:

from tabula import read_pdf

def loadPDF(pdfPath):
    # Read tables from the PDF file
    tables = read_pdf(pdfPath, pages='all', multiple_tables=True)
    #tables = tabula.io.read_pdf(pdfPath, pages='all')

    return tables

tables = loadPDF('C:\\Users\\andyo\\OneDrive\\Desktop\\Code Projects\\Example\\ExamplePDF.pdf')

When I run this python script in the editor, it executes without error and I can continue working with the extracted dataframes.

After compiling the script into a standalone .exe and running it, this unhandled exception occurs:

Failed to execute script 'MinimumExample' due to unhandled exception: Command '['java','-Dfile.encoding=UTF8','-jar','C:\Users\andyo\AppData\Local\Temp\_MEI209242\tabula\tabula-1.0.5-jar-with-dependencies.jar','--pages','all','--guess','--format','JSON','C:\Users\andyo\OneDrive\Desktop\Code Projects\Example\ExamplePDF.pdf']' returned non-zero exitstatus 1.

Traceback (most recent call last): File "MinimumExample.py", line 9, in File "MinimumExample.py", line 6, in loadPDF File "tabula\io.py", line 425, in read_pdf File "tabula\io.py", line 88, in _run File "subprocess.py", line 571, in run subprocess.CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'C:\Users\andyo\AppData\Local\Temp\_MEI209242\tabula\tabula-1.0.5-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', 'C:\Users\andyo\OneDrive\Desktop\Code Projects\Example\ExamplePDF.pdf']' returned non-zero exit status 1.

The command used to create the .exe:

PS C:\Users\andyo> python -m PyInstaller --onefile 'C:\Users\andyo\OneDrive\Desktop\Code Projects\Example\MinimumExample.py' --windowed --name "Minimum Example" -i='C:\Users\andyo\OneDrive\Desktop\Code Projects\Example\icon.ico'

Setup:

Using Python 3.12 Reinstalled tabula-py==2.7.0 due to an issue with the later 2.8 version. Fresh install of java.

Found this relevant question, but could not solve it. Tabula doesn't work after converting python script to .exe

0

There are 0 best solutions below