2017-06-12 66 views
0

皆、私はpdfsからテーブルを抽出するためにpythonでtabula-pyを使用しています。私は次のコードを使用しました。"Javaが見つかりません" tabula-pyを使用しています

import tabula 

table_temp = tabula.read_pdf('./example_pdf/sample1.pdf',pages=11) 

ただし、私は「このようなファイルまたはディレクトリはありません」というメッセージが表示されました。私は次のフォルダにJavaをインストールしました

"/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home". 

誰かが問題を解決するのに役立つでしょうか?

ありがとうございました。


FileNotFoundError       Traceback (most recent call last) 
<ipython-input-4-41c9ba6fd519> in <module>() 
----> 1 table_temp = tabula.read_pdf('./example_pdf/sample1.pdf',pages=11) 

/Users/Myworld/anaconda/lib/python3.5/site-packages/tabula/wrapper.py in read_pdf(input_path, **kwargs) 
    64 
    65  try: 
---> 66   output = subprocess.check_output(args) 
    67  finally: 
    68   if is_url: 

/Users/Myworld/anaconda/lib/python3.5/subprocess.py in check_output(timeout, *popenargs, **kwargs) 
    314 
    315  return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, 
--> 316    **kwargs).stdout 
    317 
    318 

/Users/Myworld/anaconda/lib/python3.5/subprocess.py in run(input, timeout, check, *popenargs, **kwargs) 
    381   kwargs['stdin'] = PIPE 
    382 
--> 383  with Popen(*popenargs, **kwargs) as process: 
    384   try: 
    385    stdout, stderr = process.communicate(input, timeout=timeout) 

/Users/Myworld/anaconda/lib/python3.5/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds) 
    674         c2pread, c2pwrite, 
    675         errread, errwrite, 
--> 676         restore_signals, start_new_session) 
    677   except: 
    678    # Cleanup if the child failed starting. 

/Users/Myworld/anaconda/lib/python3.5/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) 
    1280        else: 
    1281         err_msg += ': ' + repr(orig_executable) 
-> 1282      raise child_exception_type(errno_num, err_msg) 
    1283     raise child_exception_type(err_msg) 
    1284 

FileNotFoundError: [Errno 2] No such file or directory: 'java' 
+0

は、パスに登録された 'java'実行可能ファイルですか?もしそうなら、あなたのosコマンドラインユーティリティ(例えば、cmd、bash)から 'java --version'を実行できるはずです。とにかくあなたのOSは何ですか? –

+1

あなたのコメントに感謝します。私がMacでターミナルでjava --versionをタイプしたとき、私は "-bash:java:command not found"を得ました。 –

+0

それから 'java/bin'ディレクトリをあなたのツールによってロードされるパスに置く必要があります。ubuntuやcentosでは' .bashrc'になります。それを見てみてください。 –

答えて

0

私は同じエラーに遭遇していました。実際に私にエラーを引き起こす行はsubprocess.call('java')でした。

Installing java私のマシンでエラーが修正されました。

javaをインストールしても問題が解決しない場合は、which javaを実行し、出力ディレクトリをPATH環境変数に追加してください。

HTH

関連する問題