Alex Rivera | Logout

NLTK fails to find the Java executable

Asked 2011-09-13T15:46:27.437
22

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

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"

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 "/". 

However the nltk still cannot find it.

Anyone has idea about what's going wrong? Thanks a loooot!

Edit
Report

2 Answers

1

Another possibility when facing this error message while using the stanford package in NLTK is if you use StanfordTagger instead of PosTagger or NERTagger. According to Google Groups, there was a design to encourage users away from the general StanfordTagger class and towards one of the two specific taggers.

answered 2013-01-22T13:43:37.333
1

Hopefully this saves someone else some time when trying to fix this problem. I'm pretty new to programming, Python and the NLTK, and didn't realize when I was trying to implement @dduhaime's solution that there are two 'internals.py' files: one in the nltk folder (path=C:\nltk-2.0.4 on my computer) and one in my Python27 folder (path=C:\Python27\Lib\site-packages\nltk-2.0.4-py2.7.egg\nltk on my computer). You have to add the path to the java directory on lines 69 & 72 in the latter 'internals.py' file, or the NLTK will still not be able to find it.

My environment: Windows 7 64 bit, NLTK build 2.0.4

answered 2013-07-11T18:29:01.923

Your Answer