I'm trying to use Tabula-py to do some data scraping from PDF's however I can't get quite it to work. I'm running this in my Jupyter notebook (on a Mac):
from tabula import read_pdf
df = read_pdf("/Users/jamesozden/Downloads/pdfminer-20140328/samples/simple1.pdf")
And I'm getting this error:
Error:
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-5-57f646d3a440> in <module>()
----> 1 df = read_pdf("/Users/jamesozden/Downloads/pdfminer-20140328/samples/simple1.pdf")
2 #/Users/jamesozden/Desktop/data_scrape_table.pdf
/Users/jamesozden/anaconda/lib/python2.7/site-packages/tabula/wrapper.pyc in read_pdf(input_path, output_format, encoding, java_options, pandas_options, multiple_tables, **kwargs)
83
84 try:
---> 85 output = subprocess.check_output(args)
86
87 except FileNotFoundError as e:
/Users/jamesozden/anaconda/lib/python2.7/subprocess.pyc in check_output(*popenargs, **kwargs)
217 if cmd is None:
218 cmd = popenargs[0]
--> 219 raise CalledProcessError(retcode, cmd, output=output)
220 return output
221
CalledProcessError: Command '['java', '-jar', '/Users/jamesozden/anaconda/lib/python2.7/site-packages/tabula/tabula-1.0.1-jar-with-dependencies.jar', '--pages', '1', '--guess', '/Users/jamesozden/Downloads/pdfminer-20140328/samples/simple1.pdf']' returned non-zero exit status 1
So I read some previous questions about having java installed, which I do. I also made sure I added the path to my bash profile (I'm relatively new to this so I'm not sure if I've done it correctly). Here is the line I added to my bash.profile in case anyone wants to make sure it's okay, which I got from using which java
:
export PATH="$HOME/usr/bin/java/bin:$PATH"
Any help would be much appreciated, thank you!
I managed to sort it myself! Turns out even though I had downloaded the updated version of Java, version 1.6 was the one being used (this one seen using java -version). I used homebrew to upgrade to java 8 and now it is working fine.