gpt4 book ai didi

java - 在 python 3.4 中使用 java 和 nltk

转载 作者:行者123 更新时间:2023-12-01 11:58:31 25 4
gpt4 key购买 nike

我想在我的项目中使用 stanford-tagger,但出现以下错误。

  File "C:\Python34\lib\site-packages\nltk\tag\stanford.py", line 59, in tag
return self.tag_sents([tokens])[0]
File "C:\Python34\lib\site-packages\hazm\POSTagger.py", line 25, in tag_sents
return super(stanford.POSTagger, self).tag_sents(refined)
File "C:\Python34\lib\site-packages\nltk\tag\stanford.py", line 64, in tag_sents
config_java(options=self.java_options, verbose=False)
File "C:\Python34\lib\site-packages\nltk\internals.py", line 82, in config_java
_java_bin = find_binary('java', bin, env_vars=['JAVAHOME', 'JAVA_HOME'], verbose=verbose, binary_names=['java.exe'])
File "C:\Python34\lib\site-packages\nltk\internals.py", line 544, in find_binary
binary_names, url, verbose))
File "C:\Python34\lib\site-packages\nltk\internals.py", line 538, in find_binary_iter
url, verbose):
File "C:\Python34\lib\site-packages\nltk\internals.py", line 517, in find_file_iter
raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
LookupError:

===========================================================================
NLTK was unable to find the java file!
Use software specific configuration paramaters or set the JAVAHOME environment variable.
===========================================================================

NLTK 无法找到 java 文件!使用软件特定的配置参数或设置 JAVAHOME 环境变量。

请帮我设置java变量。我使用 Windows 8 64 位和 python 3.4

最佳答案

将其添加到您的代码中:

java_path = "C:/Program Files/Java/jdk1.8.0_191/bin/java.exe"
os.environ['JAVAHOME'] = java_path

关于java - 在 python 3.4 中使用 java 和 nltk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28164510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com