我正在尝试将grammar-check 1.3.1
库用于Python
我已经使用pip命令安装了它
$ pip install --upgrade 3to2
$ pip install --upgrade language-check
我还从this link解压缩LanguageTool文件并将其移至
C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check
然后我尝试运行一个测试程序
import grammar_check as gc
with open("file.txt") as f:
tool = gc.LanguageTool('en-US')
matches = tool.check(f.read())
print len(matches)
但是我得到这个错误
File "lang-grammar-checker.py", line 22, in main
tool = gc.LanguageTool(predicted)
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 190, in __init__
self._start_server_on_free_port()
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 318, in _start_server_on_free_port
cls._start_server()
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 330, in _start_server
server_cmd = get_server_cmd(cls._port)
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 541, in get_server_cmd
java_path, jar_path = get_jar_info()
File "C:\Users\me\AppData\Roaming\Python\Python27\site-packages\grammar_check\__init__.py", line 554, in get_jar_info
raise JavaError(u"can't find Java")
grammar_check.JavaError: can't find Java
我的计算机上也安装了Java8。我该如何解决这个错误?
最佳答案
问题是您的系统看不到Java。您可以通过键入以下命令来检查系统是否“知道” java:
java -version
在命令提示符下(无需转到Java位置!)。
您可以将其添加到环境变量PATH中,以实现Java开发工具包的位置。
How do I set or change the PATH system variable?
关于python - Python 2.7-使用语法检查1.3.1库时出现JavaError,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45377463/