Cannot use the Translator() function from googletrans module in Python
Question:
I’m using this code to translate the string ‘Hola mundo’:
text = 'Hola mundo'
from googletrans import Translator
Translator().translate(text)
But I obtain this error:
AttributeError: ‘NoneType’ object has no attribute ‘group’
I’m using Jupyter Notebook with Python version 3.9 and pip version 21.2.4.
Could someone help me with this issue? Thank you in advance!
Answers:
You have to create an instance of Translator to use this API
from googletrans import Translator
translator = Translator()
translator.translate(text)
I tried installing the 4.0.0rc1 version for googletrans module and it works!
Thank you 🙂
I’m using this code to translate the string ‘Hola mundo’:
text = 'Hola mundo'
from googletrans import Translator
Translator().translate(text)
But I obtain this error:
AttributeError: ‘NoneType’ object has no attribute ‘group’
I’m using Jupyter Notebook with Python version 3.9 and pip version 21.2.4.
Could someone help me with this issue? Thank you in advance!
You have to create an instance of Translator to use this API
from googletrans import Translator
translator = Translator()
translator.translate(text)
I tried installing the 4.0.0rc1 version for googletrans module and it works!
Thank you 🙂