gpt4 book ai didi

python - 表格 python : Getting subprocess. CalledProcessError : Command '[' java', '-Dfile.encoding=UTF8',错误

转载 作者:行者123 更新时间:2023-12-05 07:15:04 31 4
gpt4 key购买 nike

我收到 subprocess.CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', error while running tabula python liberary.

命令:

df = tabula.read_pdf(filepath, pages = 5 ,guess=True, multiple_tables= True, stream=True, java_options="-Dfile.encoding=UTF8")

错误信息:

  File "C:\Users\himsoni\AppData\Local\Programs\Python\Python37\lib\site-packages\tabula\io.py", line 85, in _run
check=True,
File "C:\Users\himsoni\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'C:\\Users\\himsoni\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\tabula\\tabula-1.0.3-jar-with-dependencies.jar', '--pages', '1', '--stream', '--guess', '--format', 'JSON', 'C:\\Users\\himsoni\\Desktop\\PDF_extraction\\black_white_format\\black_white_format\\PDF_Split_JPEGs\\blackwhite_Test.pdf']' returned non-zero exit status 1.

导入表格; tabula.environment_info()

Python version:
3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
Java version:
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) Client VM (build 25.231-b11, mixed mode, sharing)
tabula-py version: 2.0.1
platform: Windows-10-10.0.17763-SP0
uname:
uname_result(system='Windows', node='himsoni', release='10', version='10.0.17763', machine='AMD64', processor='Intel64 Family 6 Model 142 Stepping 10, GenuineIntel')
linux_distribution: ('', '', '')
mac_ver: ('', ('', '', ''), '')

Python 和 Java 版本

Python 3.7.4
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) Client VM (build 25.231-b11, mixed mode)
Does java -h command work well?; Yes
Ensure your java command is included in PATH Yes
Write your OS and it's version: ? Windows 10

代码:

import tabula
filepath = "C:\\Users\\himsoni\\Desktop\PDF_extraction\\black_white_format\\black_white_format\\PDF_Split_JPEGs\\blackwhite.pdf"
df = tabula.read_pdf(filepath, pages = 5 ,guess=True, multiple_tables= True, stream=True, java_options="-Dfile.encoding=UTF8")
print(df)

预期输出:获取特定页面的表格。

最佳答案

我的 PDF 包含这个字体描述符对象:

17 0 obj
<</Ascent 891 /CapHeight 662 /Descent -216 /Flags 32 /FontBBox
[-497 -306 1120 1023] /FontFile2 18 0 R /FontName
/AFPTimesNewRoman-Italic /ItalicAngle -17.-21823 /StemV 80 /Type
/FontDescriptor /XHeight 441>>
endobj

根据 PDF 规范,ItalicAngle 必须是一个数字。 -17.-21823 不是有效的数字表示法。因此,不在引擎盖下进行修复的 PDF 解析器很可能无法读取您的文件。 PDFBox 确实失败了。

PS:答案由 tabula pdf/tabula-java 开发团队提供。

关于python - 表格 python : Getting subprocess. CalledProcessError : Command '[' java', '-Dfile.encoding=UTF8',错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59734775/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com