NLTK无法找到Java可执行文件 [英] NLTK fails to find the Java executable

查看:658
本文介绍了NLTK无法找到Java可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NLTK的nltk.tag.stanford,它需要调用java可执行文件。

I am using NLTK's nltk.tag.stanford, which needs to call the java executable.

我将JAVAHOME设置为C:\Program Files \ Java \\ jdk1.6.0_25安装了我的jdk,但是在运行程序时我收到错误

I set JAVAHOME to C:\Program Files\Java\jdk1.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.

任何人都知道出了什么问题?感谢loooot!

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可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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