首页 > 解决方案 > 在 python 3.6 上运行 tabula.read_pdf() 函数时获取“CalledProcessError ....返回非零退出状态 1”

问题描述

我已经尝试了所有可能的选择。请帮忙

在 python 中运行 tabula 的 read_pdf() 时出现以下错误。错误是

CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'D:\\Transfer_Folder\\WPy-3661\\python-3.6.6.amd64\\lib\\site-packages\\tabula\\tabula-1.0.3-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', '--outfile', 'C:\\Users\\guptac\\AppData\\Local\\Temp\\tmpqu_wgv1o', 'C:/Users/guptac/Desktop/1409.3215.pdf']' returned non-zero exit status 1.

运行时tabula.environment_info()

我得到以下信息:

Python version:
    3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)]
Java version:
    java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
tabula-py version: 1.4.0
platform: Windows-10-10.0.17763-SP0
uname:
    uname_result(system='Windows', node='Guptacdt02', release='10', version='10.0.17763', machine='AMD64', processor='Intel64 Family 6 Model 158 Stepping 9, GenuineIntel')
linux_distribution: ('MSYS_NT-10.0-WOW', '2.10.0', '')
mac_ver: ('', ('', '', ''), '')

我已经尝试保留我的程序文件,即我在桌面上编写了上面称为 untitled0.py 的代码的位置,以及我试图在桌面上处理的文本文件。我从 Stackoverflow 中看到无数选项,例如获取 Java 7 而不是 Java 8 将解决我的问题,升级 tabula 包(我发现它已经是最新版本)并且我的 Java 也已更新。有人在另一篇文章的评论中说将代码和pdf保存在我所做的同一目录中,但无济于事。上面的错误信息不断出现。

import tabula

df = tabula.read_pdf('C:/Users/guptac/Desktop/1409.3215.pdf',pages='all',encoding = 'utf-8',multiple_tables=True)

错误信息:

CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'D:\\Transfer_Folder\\WPy-3661\\python-3.6.6.amd64\\lib\\site-packages\\tabula\\tabula-1.0.3-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', '--outfile', 'C:\\Users\\guptac\\AppData\\Local\\Temp\\tmpqu_wgv1o', 'C:/Users/guptac/Desktop/1409.3215.pdf']' returned non-zero exit status 1.

预期结果:我应该能够解析多个表格,或者我应该说从我作为输入提供的 pdf 文档中提取多个表格

tabula.read_pdf()

更新: 也运行如下所示:https ://github.com/chezou/tabula-py/issues/93没有任何好处。请参阅下面的错误..


D:\Transfer_Folder\WPy-3661\python-3.6.6.amd64\Lib\site-packages>java -jar'D:\\Transfer_Folder\\WPy-3661\\python-3.6.6.amd64\\lib\\site-packages\\tabula\\tabula-1.0.3-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', '--outfile', 'C:\\Users\\guptac\\AppData\\Local\\Temp\\tmpi1dv4lz7', '1409.3215.pdf'
Unrecognized option: -jar'D:\\Transfer_Folder\\WPy-3661\\python-3.6.6.amd64\\lib\\site-packages\\tabula\\tabula-1.0.3-jar-with-dependencies.jar',
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

更新:

我下载的文件来源是: https ://arxiv.org/pdf/1409.3215.pdf

更新 我还检查了此处发布的解决方案,但不太明白他们建议的解决方案:

https://github.com/chezou/tabula-py/issues/60

更新

我已经放弃了对白板的希望。我改为使用 camelot..好多了。

标签: python-3.xtabulapython-camelot

解决方案


抱歉回复晚了,我知道您已经使用 camelot 而不是 tabula-py,但仅供发现此主题的人参考。

引入 v1.4.0 的是 Windows 上的问题。tabula-py v1.4.1 应该可以解决这个问题。 https://github.com/chezou/tabula-py/releases/tag/v1.4.1


推荐阅读