0

My Code:

>> from googletrans import Translator translator = Transltor()
>> translator.translate("Hello",dest="hi") # "hi"  = in hindi language

But I am getting an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "F:\YourTranslator\env\lib\site-packages\googletrans\client.py", line 182, in translate
    data = self._translate(text, dest, src, kwargs)
  File "F:\YourTranslator\env\lib\site-packages\googletrans\client.py", line 78, in _translate
    token = self.token_acquirer.do(text)
  File "F:\YourTranslator\env\lib\site-packages\googletrans\gtoken.py", line 194, in do
    self._update()
  File "F:\YourTranslator\env\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'

using python3, pip 2020 latest version Thanks In Advance

  • `RE_TKK.search(r.text)` is not returning any matches. – John Gordon Dec 05 '20 at 06:33
  • Shouldn't `translator = Transltor()` be on a separate line? Also, Transltor is misspelled; should be `translator = Translator()` – marsnebulasoup Dec 05 '20 at 06:33
  • Do you get the same error if you change the language? `RE_TKK.search(r.text)` is returning None, so perhaps there's not enough support for hindi? – vasia Dec 05 '20 at 06:33
  • Nope getting the same error if i choose french.... –  Dec 05 '20 at 06:34
  • Please show the entire error traceback. There should be a line of code after the first `File` line, but instead there's another `File`. – John Gordon Dec 05 '20 at 06:42
  • https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group Found Solution thanks god bless you –  Dec 05 '20 at 06:47
  • try `pip install googletrans==3.1.0a0` should workout – Equinox Dec 05 '20 at 06:48
  • venky__, Yes I was also saying the same...Thanks BTW –  Dec 06 '20 at 10:14
  • Does this answer your question? [googletrans stopped working with error 'NoneType' object has no attribute 'group'](https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group) – Tomerikoo Dec 06 '20 at 10:29
  • Yes, Tomerikoo this answer my question –  Dec 06 '20 at 10:34

2 Answers2

1

Alright Guys, I found the answer

first you have to uninstall your googletrans

pip install googletrans

And then install this one:

pip install googletrans==3.1.0a0

Error solved Found from here

  • If you think this question has an answer somewhere else in this site - [flag it as duplicate](https://stackoverflow.com/help/privileges/flag-posts) instead of posting a link to an answer as an answer... – Tomerikoo Dec 06 '20 at 10:29
0

I dont know if it works for you, but using google_trans_new works for me.

to install :

pip install google_trans_new

to use :

from google_trans_new import google_translator
translator = google_translator()
mystring = "pick your language"
result = translator.translate(mystring, lang_tgt = "de")
namida
  • 1
  • 1