7

I keep getting this error. I am working on -

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'

This is my code that is giving me an error.

tabula.convert_into(root.fileName, "_ExportedPDF-" + date_time + ".csv", output_format="csv", pages="all")

UPDATE:

When I try to do from tabula import wrapper I get th error:

ImportError: cannot import name 'wrapper'

UPDATE:

Fixed comment as per @L. Alvarez

Getting following error:

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,420
  • 7
  • 38
  • 60

3 Answers3

12

I suspect you did pip install tabula, which installed a tabula library that has a version 1.0.5. Here's the github repo. It does not have a convert_into function

But you actually meant to install this tabula, whose last version is 0.9.0

You should pip uninstall tabula and pip3 install tabula-py

Luis Alvarez
  • 674
  • 6
  • 8
  • 3
    tabula-py is just a wrapper around [tabula-java](https://github.com/tabulapdf/tabula-java). Which means python is calling some Java code under the sheets. And the vague error you just got means something went wrong at the Java level. It could be anything. I recommend you at least do `java -version' and validate that your Java is version 7 or 8, which appear to be the required versions for tabula – Luis Alvarez Jul 27 '17 at 02:46
  • 1
    You could try calling the Java code directly afterward, hopefully the error you get calling the Java code directly is less vague – Luis Alvarez Jul 27 '17 at 02:47
  • I'm still getting this error even with Java installed and no tabula package installed... – Andrew Schultz Feb 27 '19 at 15:32
2

CalledProcessError: Command '['java', '-jar', '/lib/python2.7/site-packages/tabula/tabula-1.0.1-jar-with-dependencies.jar', '--pages', '1', '--guess',]' returned non-zero exit status 1

If you are getting above error then it means you have to install java-jre and java-jdk

sudo apt-get install default-jre

sudo apt-get install default-jdk

you can follow the steps here if the above installation dosent work https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

Community
  • 1
  • 1
Shinto Joseph
  • 2,809
  • 27
  • 25
0

just do these 2 steps :

  1. pip uninstall tabula
  2. pip3 install tabula-py execute these in your command prompt

and your error will be solved.