Python的tabula模块发生了什么错误?

7

我一直遇到这个错误。我正在使用 -

Mac Sierra 10.8

Python 3.6.2

tabula 1.0.5

注:此处未提供错误信息,如需翻译请提供完整内容。
Traceback (most recent call last):
  File "/Users/Sam/Desktop/mitch test/test.py", line 22, in <module>
    tabula.convert_into(root.fileName, "_ExportedPDF-" + date_time + ".csv", output_format="csv", pages="all")
AttributeError: module 'tabula' has no attribute 'convert_into'

这是我遇到错误的代码。
tabula.convert_into(root.fileName, "_ExportedPDF-" + date_time + ".csv", output_format="csv", pages="all")

更新:
当我尝试使用from tabula import wrapper时,我遇到了错误:
ImportError: cannot import name 'wrapper'

更新:
根据@L. Alvarez的评论已修正。
遇到以下错误:
Traceback (most recent call last):
  File "/Users/Sam/Desktop/mitch test/test.py", line 22, in <module>
    tabula.convert_into(root.fileName, "_ExportedPDF-" + date_time + ".csv", output_format="csv", pages="all")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tabula/wrapper.py", line 140, in convert_into
    subprocess.check_output(args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout 
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['java', '-jar', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tabula/tabula-0.9.2-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'CSV', '--outfile', '_ExportedPDF-Jul 26 2017.csv', '/Users/Sam/Desktop/mitch test/security_by_curr_risk_ldw.pdf']' returned non-zero exit status 1.

我有很多代码,但是我试图将其放在另一台计算机上并且一直收到错误消息。 - sgerbhctim
3个回答

12
我怀疑您执行了pip install tabula命令,这个命令安装了一个版本为1.0.5的tabula库。这是github库的链接,它没有convert_into函数。
但实际上您想要安装的是这个tabula,其最新版本是0.9.0。
您需要执行pip uninstall tabula然后执行pip3 install tabula-py来安装正确的版本。

3
tabula-py只是tabula-java的一个包装器,这意味着Python在底层调用了一些Java代码。而你刚刚遇到的模糊错误意味着Java出了问题,可能是任何原因。我建议您至少执行java -version命令,并验证您的Java版本是否为7或8,这似乎是tabula所需的版本。 - Luis Alvarez
1
你可以尝试直接调用Java代码,希望直接调用Java代码时出现的错误不那么模糊。 - Luis Alvarez
即使已安装Java并未安装tabula包,我仍然遇到此错误。 - Andrew Schultz

2

CalledProcessError: 命令 '['java', '-jar', '/lib/python2.7/site-packages/tabula/tabula-1.0.1-jar-with-dependencies.jar', '--pages', '1', '--guess',]' 返回非零退出状态 1

如果你遇到上述错误,那么说明你需要安装java-jre和java-jdk

sudo apt-get install default-jre

sudo apt-get install default-jdk

如果上述安装方法不起作用,您可以按照以下步骤进行操作:https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

0

只需执行以下两个步骤:

  1. pip uninstall tabula
  2. pip3 install tabula-py 在命令提示符中执行这些命令

这样你的错误将会得到解决。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接