Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python (googletrans) - AttributeError: 'NoneType' object has no attribute 'group'

Trying to detect language code in Python using googletrans. But it generating ERROR (Refer error block for info).

Require solution for the same

Code :

import googletrans
from googletrans import Translator
translator = Translator()
result = translator.translate('Mitä sinä teet')
print(result.src)
print(result.dest)
print(result.origin)
print(result.text)
print(result.pronunciation)

Error:


C:\ProgramData\Anaconda3\lib\site-packages\googletrans\gtoken.py in _update(self)
     60 
     61         # this will be the same as python code after stripping out a reserved word 'var'
---> 62         code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
     63         # unescape special ascii characters such like a \x3d(=)
     64         code = code.encode().decode('unicode-escape')

AttributeError: 'NoneType' object has no attribute 'group'
like image 690
K Ashish Avatar asked Oct 19 '25 14:10

K Ashish


1 Answers

It worked post re-installing googletrans

pip install googletrans==4.0.0-rc1

like image 138
K Ashish Avatar answered Oct 22 '25 04:10

K Ashish