ModuleNotFoundError:未检测到java安装。请安装java以使用languagetoolpython

2024-04-20 02:47:09 发布

您现在位置:Python中文网/ 问答频道 /正文

如果某句话有问题,我想核对一下数字

我的代码是

import language_tool_python
tl = language_tool_python.LanguageTool('en-US')

txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
m = tl.check(txt)
len(m)

我没有返回号码,而是收到如下所示的错误消息

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-1c4c9134d6f4> in <module>
      1 import language_tool_python
----> 2 tool = language_tool_python.LanguageTool('en-US')
      3 
      4 text = "Your the best but their are allso  good !"
      5 matches = tool.check(text)

E:\Anaconda\lib\site-packages\language_tool_python\server.py in __init__(self, language, motherTongue, remote_server, newSpellings, new_spellings_persist)
     43             self._update_remote_server_config(self._url)
     44         elif not self._server_is_alive():
---> 45             self._start_server_on_free_port()
     46         if language is None:
     47             try:

E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_server_on_free_port(self)
    212             self._url = 'http://{}:{}/v2/'.format(self._HOST, self._port)
    213             try:
--> 214                 self._start_local_server()
    215                 break
    216             except ServerError:

E:\Anaconda\lib\site-packages\language_tool_python\server.py in _start_local_server(self)
    222     def _start_local_server(self):
    223         # Before starting local server, download language tool if needed.
--> 224         download_lt()
    225         err = None
    226         try:

E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in download_lt(update)
    142     ]
    143 
--> 144     confirm_java_compatibility()
    145     version = LATEST_VERSION
    146     filename = FILENAME.format(version=version)

E:\Anaconda\lib\site-packages\language_tool_python\download_lt.py in confirm_java_compatibility()
     73         # found because of a PATHEXT-related issue
     74         # (https://bugs.python.org/issue2200).
---> 75         raise ModuleNotFoundError('No java install detected. Please install java to use language-tool-python.')
     76 
     77     output = subprocess.check_output([java_path, '-version'],

ModuleNotFoundError: No java install detected. Please install java to use language-tool-python.

当我运行代码时,没有检测到java安装 如何解决这个问题


Tags: inpyltselfserverdownloadlibpackages
1条回答
网友
1楼 · 发布于 2024-04-20 02:47:09

当我运行您提供的代码时,我认为这不是代码本身的问题

import language_tool_python
tl = language_tool_python.LanguageTool('en-US')

txt = "good mooorning sirr and medam my namee anderen i am from amerecia !"
m = tl.check(txt)
len(m)

在这种情况下,我得到的结果是一个数字

 OUT: 8

language-tool-python的文件中写道:

By default, language_tool_python will download a LanguageTool server .jar and run that in the background to detect grammar errors locally. However, LanguageTool also offers a Public HTTP Proofreading API that is supported as well. Follow the link for rate-limiting details. (Running locally won't have the same restrictions.)

因此,您将需要Java(JRE和SKD)。图书馆的要求中也写着:

Prerequisites Python 3.5+ LanguageTool (Java 8.0 or higher) The installation process should take care of downloading LanguageTool (it may take a few minutes). Otherwise, you can manually download LanguageTool-stable.zip and unzip it into where the language_tool_python package resides.

资料来源:

我希望我能帮忙

相关问题 更多 >