Googletrans抛出ConnectTimeout错误(握手操作超时) [英] Googletrans throws a ConnectTimeout error (the handshake operation timed out)
本文介绍了Googletrans抛出ConnectTimeout错误(握手操作超时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用Python 3.8.5进行翻译,但未得到适当的结果.到目前为止,我的代码是
I am currently working on a translator in Python 3.8.5 but I am not getting an appropriate result. My code thus far is
from googletrans import Translator
text = '''Vous êtes français'''
translator = Translator()
dt = translator.detect(text)
print(dt)
在我的终端中,我应该获取源和目标对于Source来说是fr,对于 dt
来说en,但是我得到的是这个错误,我不知道如何解决.
In my terminal, I should be getting the source and the destination
which is fr for Source and en for dt
but instead what I am getting is this error I have no idea how to fix.
Traceback (most recent call last):
File "c:/Users/Akash/Desktop/Learning python/Project10-MegaProject-Translator.py", line 5, in <module>
dt = translator.detect(text)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\client.py", line 255, in detect
data = self._translate(text, 'en', 'auto', kwargs)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\client.py", line 78, in _translate
token = self.token_acquirer.do(text)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\gtoken.py", line 194, in do
self._update()
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\gtoken.py", line 54, in _update
r = self.client.get(self.host)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 755, in get
return self.request(
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 600, in request
return self.send(
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 620, in send
response = self.send_handling_redirects(
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 647, in send_handling_redirects
response = self.send_handling_auth(
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 684, in send_handling_auth
response = self.send_single_request(request, timeout)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 714, in send_single_request
) = transport.request(
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\connection_pool.py", line 152, in request
response = connection.request(
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\connection.py", line 65, in request
self.socket = self._open_socket(timeout)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\connection.py", line 85, in _open_socket
return self.backend.open_tcp_stream(
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_backends\sync.py", line 139, in open_tcp_stream
return SyncSocketStream(sock=sock)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\Akash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_exceptions.py", line 12, in map_exceptions
raise to_exc(exc) from None
httpcore._exceptions.ConnectTimeout: _ssl.c:1106: The handshake operation timed out
PS C:\Users\Akash\Desktop\Learning python>
推荐答案
只需更改变量的名称即可使用
Just change the name of variable and it works
这篇关于Googletrans抛出ConnectTimeout错误(握手操作超时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文