我创建了一个脚本,使用tabula-py和PyPDF2从pdf提取数据。当我通过Jupyter-notebook和cmd运行程序时,它可以完美运行。使用pyinstaller将其转换为可执行文件后,出现以下错误:

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


我也找不到指定路径上的文件夹_MEI175522。

我的python版本是3.7.1
Java版本为1.8
pyinstaller版本是3.4
Tabula-py是最新版本

如何解决此问题?

最佳答案

我遇到了类似的问题,并且可以使用此链接上的解决方案来解决它:Unable to access jarfile 'tabula-1.0.2-jar-with-dependencies.jar'

我在虚拟环境中构建了我的应用程序,因此我在tabula文件夹中添加了tabula-1.0.2-jar-with-dependencies.jar文件夹和site-packages文件。运行命令pyinstaller --add-data apps\Lib\site-packages\tabula\tabula-1.0.2-jar-with-dependencies.jar;tabula --onefile Table_OCR.py为我正确构建可执行文件。

07-26 07:35