googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’

Update 06.12.20: A new ‘official’ alpha version of googletrans with a fix was released

Install the alpha version like this:

pip install googletrans==3.1.0a0

Translation example:

translator = Translator()
translation = translator.translate("Der Himmel ist blau und ich mag Bananen", dest="en")
print(translation.text)
#output: 'The sky is blue and I like bananas'

In case it does not work, try to specify the service url like this:

from googletrans import Translator
translator = Translator(service_urls=['translate.googleapis.com'])
translator.translate("Der Himmel ist blau und ich mag Bananen", dest="en")

See the discussion here for details and updates: https://github.com/ssut/py-googletrans/pull/237

Update 10.12.20: Another fix was released

As pointed out by @DesiKeki and @Ahmed Breem, there is another fix which seems to work for several people:

pip install googletrans==4.0.0-rc1

Github discussion here: https://github.com/ssut/py-googletrans/issues/234#issuecomment-742460612

In case the fixes above don’t work for you

If the above doesn’t work for you, google_trans_new seems to be a good alternative that works for some people. It’s unclear why the fix above works for some and doesn’t for others. See details on installation and usage here: 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('สวัสดีจีน',lang_tgt="en")  
print(translate_text)
#output: Hello china

Leave a Comment