Home > Back-end >  Attribute-error in google translator function
Attribute-error in google translator function

Time:04-18

I am trying to create a translator function with a google translator. The code I have so far is very basic:

from googletrans import Translator
translator = Translator()
result = translator.translate('Mitä sinä teet')

But everytime I get the same error: AttributeError: 'NoneType' object has no attribute 'group'

How do I solve this: thanks in advance!

CodePudding user response:

There seems to be an issue with the package you are using. You can use the package translators instead.

Here is an example on how to use it:

import translators as ts
result = ts.google('Mitä sinä teet', to_language='en')
print(result)

You can find a more detailed explanation in this tutorial or in the official documentation.

  • Related