简体   繁体   English

安装了两个版本的 Java 的错误 Python 表格

[英]Error Python tabula with two versions of Java installed

I have 2 versions of Java installed, one for tabula-py, and the other for Teradata (work-related).我安装了 2 个版本的 Java,一个用于 tabula-py,另一个用于 Teradata(与工作相关)。 I've only been able to get Java 1.8 to work with tabula-py, and 1.7 is what works with our version of Teradata in my company.我只能让 Java 1.8 与 tabula-py 一起使用,而 1.7 与我们公司的 Teradata 版本一起使用。

I've removed any environment variable reference to java, with the exception of version 1.8, which I did by creating its own variable and adding it to the 'PATH' (%JAVA_HOME%\bin).我已经删除了对 java 的所有环境变量引用,但版本 1.8 除外,我通过创建自己的变量并将其添加到“PATH”(%JAVA_HOME%\bin) 中。 However, it doesn't matter what I do, it always returns an error that the java filepath doesn't exist.但是,不管我做什么,它总是返回一个错误,即 java 文件路径不存在。 When I uninstall 1.7 it works every time, but whenever I have it installed it breaks.当我卸载 1.7 时,它每次都可以工作,但每当我安装它时,它就会中断。 When I check for the java version on the command line it returns: ''' Java version “1.7.0_80” ''' I've looked through the code, and in util.py I saw that it referenced 'subprocess.check_output' using the code below:当我在命令行上检查 java 版本时,它返回:''' Java 版本“1.7.0_80” '''我查看了代码,在 util.py 中我看到它引用了 'subprocess.check_output'使用下面的代码:

''' res = subprocess.check_output(["java", "-version"], stderr=subprocess.STDOUT) ''' ''' res = subprocess.check_output(["java", "-version"], stderr=subprocess.STDOUT) '''

After researching a bit, I read that it has something to do with shell vs echo/bin.经过一番研究,我读到它与 shell 与 echo/bin 有关。 I can't make any sense of it.我无法理解它。 ( Python: Exporting environment variables in subprocess.Popen(..) ) Python:在 subprocess.Popen(..) 中导出环境变量

Could someone please help me know what I'm doing wrong?有人可以帮我知道我做错了什么吗?

You can use only one version of java at a time, which path is set in environment variable in priority, but alternatively you can set temporary path from command prompt and you can select whatever version you want to use.您一次只能使用一个版本的 java,该路径优先在环境变量中设置,但您也可以从命令提示符设置临时路径,您可以使用 select 任何版本。

In command prompt just use this command在命令提示符下只需使用此命令

set path=C:\Program Files\Java\jdk1.8.0_161\bin

Note : You have to set path every time when you open command prompt as this is a temporary path.注意:每次打开命令提示符时都必须设置路径,因为这是一个临时路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM