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


Asked By – steveJ

I was trying googletrans and it was working quite well. Since this morning I started getting below error. I went through multiple posts from stackoverflow and other sites and found probably my ip is banned to use the service for sometime. I tried using multiple service provider internet that has different ip and stil facing the same issue ? I also tried to use googletrans on different laptops , still same issue ..Is googletrans package broken or something google did at their end ?

>>> from googletrans import Translator
>>> translator = Translator()
>>> translator.translate('안녕하세요.')

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/", line 172, in translate
    data = self._translate(text, dest, src)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/", line 75, in _translate
    token =
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/", line 180, in do
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/googletrans/", line 59, in _update
    code = unicode('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

Now we will see solution for issue: googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’


Update 01/12/2020: This issue re-emerged lately, (apparently) caused once again by some changes on the Google translation API.

A solution is being discussed (again) in this Github issue. Although there is not a definitive solution yet a Pull Request seem to be solving the problem:

While we wait for it to be approved it can be installed like this:

$ pip uninstall googletrans
$ git clone
$ cd ./py-googletrans
$ git checkout origin/feature/enhance-use-of-direct-api
$ python install

Original Answer:

Apparently it’s a recent and widespread problem on Google’s side.
Quoting various Github discussions, it happens when Google sends you directly the raw token.

It’s being discussed right now and there is already a pull request to fix it, so it should be resolved in the next few days.

For reference, see: <– exact same problem reported on the Github repo <– seemingly same problem on a text-to-speech library <– pull request to fix the issue

To apply this patch (without waiting for the pull request to be accepted) simply install the library from the forked repo (uninstall the official library first):

$ pip uninstall googletrans
$ git clone
$ cd ./py-googletrans
$ python install

You can clone it anywhere on your system and install it globally or while inside a virtualenv.

This question is answered By – Maldus

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0