1

在使用language_tool_python包查找语法错误时,我发现了以下异常:

Exception: Could not find at URL https://www.languagetool.org/download/LanguageTool-5.5.zip.

我正在使用 Mac M1,必须从 Azul Zulu 安装Java 17(也尝试过 Java 8),这样它才能识别 Java 模块。

在 Linux 上,工作正常。

好像是url有问题,但是我们直接去的时候文件是存在的!

https://www.languagetool.org/download/LanguageTool-5.5.zip

也尝试了 2.5 版,但我得到了相同的结果。

有解决方法吗?

谢谢!

这里的追溯:

Exception                                 Traceback (most recent call last)
/var/folders/d_/hfs18jf54371qfmf54zq289c0000gn/T/ipykernel_33610/1177712971.py in <module>
----> 1 tool = language_tool_python.LanguageTool('en-US')

~/miniforge3/envs/transformers/lib/python3.9/site-packages/language_tool_python/server.py in __init__(self, language, motherTongue, remote_server, newSpellings)
     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:

~/miniforge3/envs/transformers/lib/python3.9/site-packages/language_tool_python/server.py in _start_server_on_free_port(self)
    179             self._url = 'http://{}:{}/v2/'.format(self._HOST, self._port)
    180             try:
--> 181                 self._start_local_server()
    182                 break
    183             except ServerError:

~/miniforge3/envs/transformers/lib/python3.9/site-packages/language_tool_python/server.py in _start_local_server(self)
    189     def _start_local_server(self):
    190         # Before starting local server, download language tool if needed.
--> 191         download_lt()
    192         err = None
    193         try:

~/miniforge3/envs/transformers/lib/python3.9/site-packages/language_tool_python/download_lt.py in download_lt(update)
    152         return
    153 
--> 154     download_zip(language_tool_download_url, download_folder)
    155 
    156 if __name__ == '__main__':

~/miniforge3/envs/transformers/lib/python3.9/site-packages/language_tool_python/download_lt.py in download_zip(url, directory)
    123     # Download file.
    124     downloaded_file = tempfile.NamedTemporaryFile(suffix='.zip', delete=False)
--> 125     http_get(url, downloaded_file)
    126     # Close the file so we can extract it.
    127     downloaded_file.close()

~/miniforge3/envs/transformers/lib/python3.9/site-packages/language_tool_python/download_lt.py in http_get(url, out_file, proxies)
    104     total = int(content_length) if content_length is not None else None
    105     if req.status_code == 403: # Not found on AWS
--> 106         raise Exception('Could not find at URL {}.'.format(url))
    107     progress = tqdm.tqdm(unit="B", unit_scale=True, total=total, desc='Downloading LanguageTool')
    108     for chunk in req.iter_content(chunk_size=1024):

Exception: Could not find at URL https://www.languagetool.org/download/LanguageTool-5.5.zip.```
4

1 回答 1

1

不是答案:网络流量

在浏览器、开发工具、网络中:对 zip 进行重定向,用于其余跟踪。

姓名 地位 类型 发起者 尺寸 时间
collect?v=1&_v=j96&a=421817770&t=event&_s=2&dl=htt...-languagetool-org-download-languaget&z=2037529220 200 xhr 分析.js:44 22乙 211 毫秒
pingym?gm0=0&gm1=0&tivt=2549&hov=1&tth=113&intt=2&intl…0:tp=1:mt=7&sek=3697285284406464539:1638139533389 200 inside.js:1 1.3 KB 324 毫秒
Bilddt?advEntityId=819590&asId=ecf354bb-1855-2567-a204…13*,rmeas:1,rend:1,renddet:DIV.qs.sn,lt:0%7D&br=c 200 gif dcmads.js:1011 216乙 1.08 秒
文档语言工具-5.5.zip 301 文档/重定向 其他 300乙 295 毫秒
XHRcollect?t=dc&aip=1&_r=3&v=1&_v=j96&tid=UA-10824261…7377033.1638135822&_u=SCCACEABBAAAAC~&z=905256628 200 xhr 分析.js:44 22乙 195 毫秒
文档语言工具-5.5.zip 200 文档 LanguageTool-5.5.zip 11.0 KB 494 毫秒

不确定重定向是否导致问题。

于 2021-11-28T23:02:46.973 回答