Python tabula模块中的这个错误是什么?

时间:2017-07-27 02:18:36

标签: python pandas tabula

我一直收到这个错误。我正在努力 -

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.

2 个答案:

答案 0 :(得分:4)

我怀疑你做了pip install tabula,它安装了一个版本为1.0.5的tabula库。这是the github repo。它没有convert_into函数

但实际上你打算安装this tabula,其最后一个版本是0.9.0

您应该pip uninstall tabulapip3 install tabula-py

答案 1 :(得分:0)

CalledProcessError:Command'['java',' - jar','/ lib / python2.7 / site-packages / tabula / tabula-1.0.1-jar-with-depepen.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