在此Python进程中找不到`java`命令.请确保已安装Java并为`java`设置了PATH [英] `java` command is not found from this Python process. Please ensure Java is installed and PATH is set for `java`

查看:784
本文介绍了在此Python进程中找不到`java`命令.请确保已安装Java并为`java`设置了PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行以下代码时,我不知道如何解决此错误:

I don't know how to fix this error when I'm trying to run the following code:

df = wrapper.read_pdf(r'C:\End_to_End\1902\PN\Scenario1_AllCorrectMin\EPR.pdf')

日志:

FileNotFoundError                         Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\tabula\wrapper.py in read_pdf(input_path, output_format, encoding, java_options, pandas_options, multiple_tables, **kwargs)
    107     try:
--> 108         output = subprocess.check_output(args)
    109 

~\AppData\Local\Continuum\anaconda3\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)
    335     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 336                **kwargs).stdout
    337 

~\AppData\Local\Continuum\anaconda3\lib\subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
    402 
--> 403     with Popen(*popenargs, **kwargs) as process:
    404         try:

~\AppData\Local\Continuum\anaconda3\lib\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, encoding, errors)
    708                                 errread, errwrite,
--> 709                                 restore_signals, start_new_session)
    710         except:

~\AppData\Local\Continuum\anaconda3\lib\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, unused_restore_signals, unused_start_new_session)
    996                                          os.fspath(cwd) if cwd is not None else None,
--> 997                                          startupinfo)
    998             finally:

FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

JavaNotFoundError                         Traceback (most recent call last)
<ipython-input-3-010e34a004ec> in <module>()
----> 1 df = wrapper.read_pdf(r'C:\End_to_End\1902\PN\Scenario1_AllCorrectMin\EPR.pdf')

~\AppData\Local\Continuum\anaconda3\lib\site-packages\tabula\wrapper.py in read_pdf(input_path, output_format, encoding, java_options, pandas_options, multiple_tables, **kwargs)
    109 
    110     except FileNotFoundError as e:
--> 111         raise JavaNotFoundError(JAVA_NOT_FOUND_ERROR)
    112 
    113     except subprocess.CalledProcessError as e:

JavaNotFoundError: `java` command is not found from this Python process. Please ensure Java is installed and PATH is set for `java`

我尝试在环境变量中更改和创建路径,但是没有用.这是屏幕截图:

I tried changing and creating the path in the environmental variables but did not work. Here is the screenshot:

有人知道如何解决此问题吗?我有Java版本8(已通过有关Java的检查)

Does anyone know how to fix this? I have java version 8 (Checked through about java)

推荐答案

System Variables下,单击Path,然后按Edit...而不是New.然后在下一个屏幕(Path变量为Edit environment variable)中单击New并添加地址,例如C:\Program Files (x86)\Java\jre1.8.0_201\bin.按OK键,Path变量将被附加/更新.

Under the System Variables click Path and then press the Edit... instead of New. Then in the next screen (Edit environment variable for the Path variable) click New and add the address, e.g. C:\Program Files (x86)\Java\jre1.8.0_201\bin. Press OK and the Path variable will be appended/updated.

您需要重新启动环境(例如Chrome,Anaconda等),路径才能生效.

You will need to restart your environment (e.g. Chrome, Anaconda, etc) for the path to have effect.

这篇关于在此Python进程中找不到`java`命令.请确保已安装Java并为`java`设置了PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆