close

[Solved] googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to use googletrans but I am facing following error googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error Occurs ?

I am trying to use googletrans but I am facing following error.

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

How To Solve googletrans AttributeError: ‘NoneType’ object has no attribute ‘group’ Error ?

  1. How To Solve googletrans AttributeError: 'NoneType' object has no attribute 'group' Error ?

    To Solve googletrans AttributeError: 'NoneType' object has no attribute 'group' Error Install latest version of googletrans or Just use this version pip install googletrans==4.0.0-rc1 Now you can use google translate.

  2. googletrans AttributeError: 'NoneType' object has no attribute 'group'

    To Solve googletrans AttributeError: 'NoneType' object has no attribute 'group' Error Install latest version of googletrans or Just use this version pip install googletrans==4.0.0-rc1 Now you can use google translate.

Solution 1: Install latest version of googletrans

Install latest version of googletrans or Just use this version.

pip install googletrans==4.0.0-rc1

Now you can use google translate.

translator = Translator()
translation = translator.translate("Hola como estas ?", dest='en')
print(translation.text)
#output: 'Hello How are you ?'

Solution 2: Use google_trans_new

Just use google_trans_new. To install use this command.

pip install google_trans_new

Here is simple Example.

from google_trans_new import google_translator  
  
translator = google_translator()  
translate_text = translator.translate('Hola mundo!', lang_src='es', lang_tgt='en')  
print(translate_text)
-> Hello world!

Solution 3: Use this command

pip uninstall googletrans
git clone https://github.com/alainrouillon/py-googletrans.git
cd ./py-googletrans
git checkout origin/feature/enhance-use-of-direct-api
python setup.py install

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment