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

2024-05-21 14:03:40 发布

您现在位置:Python中文网/ 问答频道 /正文

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

麦克塞拉10.8

Python3.6.2

表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.

Tags: csvinpytestformatconvertoutput错误
2条回答

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

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

但实际上您打算安装this tabula,其最新版本是0.9.0

你应该pip uninstall tabulapip3 install tabula-py

相关问题 更多 >