Traceback (most recent call last):
File "E:\python3.9-64x\lib\urllib\request.py", line 1342, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "E:\python3.9-64x\lib\http\client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "E:\python3.9-64x\lib\http\client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "E:\python3.9-64x\lib\http\client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "E:\python3.9-64x\lib\http\client.py", line 1010, in _send_output
self.send(msg)
File "E:\python3.9-64x\lib\http\client.py", line 950, in send
self.connect()
File "E:\python3.9-64x\lib\http\client.py", line 1417, in connect
super().connect()
File "E:\python3.9-64x\lib\http\client.py", line 921, in connect
self.sock = self._create_connection(
File "E:\python3.9-64x\lib\socket.py", line 822, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "E:\python3.9-64x\lib\socket.py", line 953, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\python3.9-64x\lib\site-packages\translate\providers\libre.py", line 32, in get_translation
return self.api.translate(text, from_lang, self.to_lang)
File "E:\python3.9-64x\lib\site-packages\libretranslatepy\api.py", line 56, in translate
response = request.urlopen(req)
File "E:\python3.9-64x\lib\urllib\request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "E:\python3.9-64x\lib\urllib\request.py", line 517, in open
response = self._open(req, data)
File "E:\python3.9-64x\lib\urllib\request.py", line 534, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "E:\python3.9-64x\lib\urllib\request.py", line 494, in _call_chain
result = func(*args)
File "E:\python3.9-64x\lib\urllib\request.py", line 1385, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "E:\python3.9-64x\lib\urllib\request.py", line 1345, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\python截图翻译\Test.py", line 384, in command
self.execute_menu_option(id)
File "D:\python截图翻译\Test.py", line 391, in execute_menu_option
menu_action(self)
File "D:\python截图翻译\Test.py", line 456, in extract
translation = translator.translate(text)
File "E:\python3.9-64x\lib\site-packages\translate\translate.py", line 45, in translate
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
File "E:\python3.9-64x\lib\site-packages\translate\translate.py", line 45, in <genexpr>
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
File "E:\python3.9-64x\lib\site-packages\translate\providers\libre.py", line 34, in get_translation
raise TranslationError(e)
translate.exceptions.TranslationError: <urlopen error [Errno 11001] getaddrinfo failed>
当然,因为deepl的api对中国大陆不提供的原因,我决定现在去尝试一下googletrans模块