我正在尝试使用 Tabula-py 从 PDF 中抓取一些数据,但是我无法让它完全正常工作。我在我的 Jupyter 笔记本(在 Mac 上)中运行它:
from tabula import read_pdf
df = read_pdf("/Users/jamesozden/Downloads/pdfminer-20140328/samples/simple1.pdf")
我收到了这个错误:
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
因此,我阅读了一些有关安装 java 的先前问题,我这样做了。我还确保我添加了我的 bash 配置文件的路径(我对此比较陌生,所以我不确定我是否做得正确)。这是我添加到我的 bash.profile 中的行,以防有人想确保它没问题,这是我从使用中得到的which java
:
export PATH="$HOME/usr/bin/java/bin:$PATH"
任何帮助将不胜感激,谢谢!