2

I cannot execute tabula-py's read_pdf function.

It seems to be producing the following error message:

WindowsError: [Error 2] The system cannot find the file specified

With traceback:

Traceback (most recent call last):
  File "C:/Users/riley/PycharmProjects/Payroll/PayrollParsePDF.py", line 126, in <module>
    print read_pdf(r"C:\Users\riley\Desktop\Bank Statements\53591.pdf")
  File "C:\Python27\lib\site-packages\tabula\wrapper.py", line 54, in read_pdf_table
    output = subprocess.check_output(args)
  File "C:\Python27\lib\subprocess.py", line 212, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
    startupinfo)

Any insight as to why this is? It was working fine before.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Riley Hun
  • 2,541
  • 5
  • 31
  • 77
  • That file is supposed to be on your Windows Desktop, right? Tell me that you've gone to your desktop and verified that that folder is there, and that when you open the folder you can see that file and that you can double-click to open it. – Bill Bell May 16 '17 at 17:49
  • Yes, the files are there and the directory is correct – Riley Hun May 16 '17 at 18:58

1 Answers1

2

It isn't YOUR file that is not being found, it is the java executable that isn't being found. That line in tabula\wrapper.py is trying to launch the actual Tabula code, which is written in Java, and failing.

I don't know why Java would suddenly stop being found - something messed up your PATH, perhaps?

jasonharper
  • 9,450
  • 2
  • 18
  • 42
  • I believe so. It is in my PATH systems variable and when I run java from the cmd window, it executes just fine. It just doesn't seem to work when running from a script on Pycharm. – Riley Hun May 16 '17 at 19:27
  • I'm not familiar with Pycharm - try `import os; print os.environ['PATH']` within it to see what it thinks your PATH is. – jasonharper May 16 '17 at 20:14
  • Looks like Java is in the PATH according to Pycharm...C:\Program Files (x86)\Java\jdk1.8.0_111\bin;C:\Program Files\Java\jre7\bin – Riley Hun May 16 '17 at 20:31
  • Hmm, that's rather different than Java's PATH entry on my computer, but looks like it should work. You could try `import subprocess; subprocess.call("java")` in Pycharm - that launches Java in pretty much the same way Tabula tries to, and should produce a bunch of text (but no error). You could also try `path` at a command prompt (outside of Python), to see if there's something different listed for Java there. – jasonharper May 16 '17 at 21:07
  • I'm getting a new error message....Error: Cannot create file C:\data\csv\fac6292f-35b1-4ad4-8b04-f8b72e362e7d.csv – Riley Hun May 16 '17 at 21:26