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 可执行文件
基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
