Sometimes, we want to fix googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’ with Python.
In this article, we’ll look at how to fix googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’ with Python.
How to fix googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’ with Python?
To fix googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’ with Python, we can install the google_trans_new
package.
To install it, we run
pip install google_trans_new
Then we use it by writing
from google_trans_new import google_translator
translator = google_translator()
translate_text = translator.translate("Hola!", lang_src="es", lang_tgt="en")
print(translate_text)
to call translator.translate
with the text we want to translate.
We set the lang_src
to the source language.
And lang_tgt
is set to the language we want to translate to.
We get the translated text from translated_text
.
Conclusion
To fix googletrans stopped working with error ‘NoneType’ object has no attribute ‘group’ with Python, we can install the google_trans_new
package.