3

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.

2 Answers 2

8

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!

Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately couldn't find a way to return confidence, unlike from googletrans import Translator followed by translator.detect(YOUR_TEXT) returns <Detected lang=DETECTED_LANGUAGE confidence=SOME_CONFIDENCE>
1

you have to increase the googletrans version from version 3.0.0 to version 4.0.0 by typing pip install googletrans==4.0.0-rc1

1 Comment

Can you please provide more information on how this solves the problem? Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.