Search code examples
javapython-3.xpyinstallerexecutabletabula-py

Unable to execute my script when converting it to exe


I created a script to extract data from a pdf using tabula-py and PyPDF2. When I run my program through Jupyter-notebook and from the cmd, it works perfectly. After converting it to executable with pyinstaller, I get this error:

Error: Unable to access jarfile 
E:\Users\paulhong\AppData\Local\Temp\_MEI175522\tabula\tabula-1.0.2-jar-with-dependencies.jar
Error:
Traceback (most recent call last):
File "test.py", line 115, in <module>

File "test.py", line 32, in extractDataDik
tempDf = tabula.read_pdf(file, area = (72, 252, 115.2, 352.8), guess=False, pages='1')
File "site-packages\tabula\wrapper.py", line 108, in read_pdf
File "subprocess.py", line 395, in check_output
File "subprocess.py", line 487, in run
subprocess.CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 
'E:\\Users\\paulhong\\AppData\\Local\\Temp\\_MEI175522\\tabula\\tabula-1.0.2-jar-with-dependencies.jar', '--pages', '1', '--area', 
'72,252,115.2,352.8', 'E:\\Users\\paulhong\\Desktop\\Purchase Order 
2\\SKM_C45819060508450 (003).pdf']' returned non-zero exit status 1. [47140] Failed to execute script test

I also couldn't find the folder _MEI175522 on the specified path.

My python version is 3.7.1 Java version is 1.8 pyinstaller version is 3.4 Tabula-py is the latest version

How can I fix this issue?


Solution

  • I had a similar problem, and I was able to solve it using the solution at this link: Unable to access jarfile 'tabula-1.0.2-jar-with-dependencies.jar'

    I built my app within a virtual environment, so I added a tabula folder with the tabula-1.0.2-jar-with-dependencies.jar file to my site-packages folder. Running the command pyinstaller --add-data apps\Lib\site-packages\tabula\tabula-1.0.2-jar-with-dependencies.jar;tabula --onefile Table_OCR.py builds the executable correctly for me.