Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'NoneType' object has no attribute 'group' googletrans python

Windows 7

Python 3.8.2

googletrans 3.0.0

from googletrans import Translator

text = 'hello'
translator = Translator()
result = translator.translate(text).src
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\AB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\
googletrans\client.py", line 182, in translate
    data = self._translate(text, dest, src, kwargs)
  File "C:\Users\AB\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\AB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\
googletrans\gtoken.py", line 194, in do
    self._update()
  File "C:\Users\AB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\
googletrans\gtoken.py", line 62, in _update
    code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

Before everything worked fine, a little later those errors began to appear, and now this error comes out after each function call.

like image 429
Акмаль Avatar asked Apr 23 '26 18:04

Акмаль


1 Answers

Try google_trans_new. https://github.com/lushan88a/google_trans_new

pip install google_trans_new
from google_trans_new import google_translator
translator = google_translator()  
translate_text = translator.translate('Hello!',lang_src='en', lang_tgt='de')  
print(translate_text)

-> Hallo!

like image 145
Raii Avatar answered Apr 28 '26 13:04

Raii



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!