NLTK fails to find the Java executable(NLTK 找不到 Java 可执行文件)
问题描述
我用的是NLTK的nltk.tag.stanford,需要调用java可执行文件.
I am using NLTK's nltk.tag.stanford, which needs to call the java executable.
我将 JAVAHOME 设置为安装 jdk 的 C:Program FilesJavajdk1.6.0_25,但运行程序时出现错误
I set JAVAHOME to C:Program FilesJavajdk1.6.0_25 where my jdk is installed, but when run the program I get the error
"NLTK was unable to find the java executable! Use the config_java() or set the JAVAHOME variable"
然后我花了3个小时调试它并尝试了
Then I spent 3 hours on debugging it and tried
config_java("C:/Program Files/Java/jdk1.6.0_25/")
config_java("C:/Program Files/Java/jdk1.6.0_25/bin/")
and those without the ending "/".
但是 nltk 仍然找不到它.
However the nltk still cannot find it.
有人知道出了什么问题吗?非常感谢!
Anyone has idea about what's going wrong? Thanks a loooot!
推荐答案
如果设置 JAVA_HOME 环境对你没有帮助,试试这个:
If setting the JAVA_HOME environment doesn't help you, try this:
config_java()
对我不起作用.我将以下几行添加到我的代码中并且它起作用了:
config_java()
did not work for me. I add the following lines to my code and it worked:
import os
java_path = "C:/Program Files/Java/jdk1.7.0_11/bin/java.exe"
os.environ['JAVAHOME'] = java_path
我正在运行 Windows 7 64 位
I am running Windows 7 64-bit
这篇关于NLTK 找不到 Java 可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:NLTK 找不到 Java 可执行文件


基础教程推荐
- 不推荐使用 Api 注释的描述 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 大摇大摆的枚举 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 多个组件的复杂布局 2022-01-01