py-googletranslation icon indicating copy to clipboard operation
py-googletranslation copied to clipboard

Exception: Unexpected status code 429

Open jonas-nothnagel opened this issue 4 years ago • 9 comments

Hi @Saravananslb Thanks for setting up a new translate library!

Unfortunately, even for a minimal working example:

from pygoogletranslation import Translator
translator = Translator()
translator.translate('Good Morning', dest='ta')

I run into this error: Exception: Unexpected status code 429 from https://translate.google.com/_/TranslateWebserverUi/data/batchexecute after retried 3 loop with 5s delay

I upgraded to 'https://pypi.org/project/pygoogletranslation/2.0.2/' as mentioned in the closed issue, but it is still not working and throws the same error:

Exception: Unexpected status code 429 from https://translate.google.com/_/TranslateWebserverUi/data/batchexecute after retried 3 loop with 5s delay

jonas-nothnagel avatar Jan 13 '21 11:01 jonas-nothnagel

Hi @Saravananslb Thanks for setting up a new translate library!

Unfortunately, even for a minimal working example:

from pygoogletranslation import Translator
translator = Translator()
translator.translate('Good Morning', dest='ta')

I run into this error: Exception: Unexpected status code 429 from https://translate.google.com/_/TranslateWebserverUi/data/batchexecute after retried 3 loop with 5s delay

I upgraded to 'https://pypi.org/project/pygoogletranslation/2.0.2/' as mentioned in the closed issue, but it is still not working and throws the same error:

Exception: Unexpected status code 429 from https://translate.google.com/_/TranslateWebserverUi/data/batchexecute after retried 3 loop with 5s delay

could you please share the text that your are trying to translate. source lang and dest lang. please send it to [email protected] I will help you this issue.

Saravananslb avatar Jan 13 '21 11:01 Saravananslb

Hi @Saravananslb that is a kind offer, however, my data is confidential and the translation directed to only some part of it that is embedded in a long function. I hope that one of the packages py-googletranslation, google_trans_new or py-googletrans will fix their problems and I can run my code smoothly again.

jonas-nothnagel avatar Jan 14 '21 08:01 jonas-nothnagel

Hi @jonas-nothnagel and @Saravananslb, I had the same issue also, just trying to trans a single sentence though. Has there been any update? But same code runs fine on Google colab.

JSMboli avatar Jan 22 '21 17:01 JSMboli

Hi @jonas-nothnagel and @Saravananslb, I had the same issue also, just trying to trans a single sentence though. Has there been any update? But same code runs fine on Google colab.

Hi jsmboli,

Are u getting the same 429 error code.

Thanks, Saravanan

Saravananslb avatar Jan 22 '21 18:01 Saravananslb

@JSMboli I still encounter the error. Actually, for each google-trans library I've tried (and there are several implementations on github) it does not seem to work well anymore. I assume that Google changed their API.

jonas-nothnagel avatar Jan 25 '21 06:01 jonas-nothnagel

I also meet this error. I tried to translate the same sentence more than 100000 times to test its stability. It will throw such an error in the process. I guess there are too many requests to Google Translation.

Google Translate HTTP Error 429 too many requests
The HTTP 429 Too Many Requests response status code indicates the user has sent too many requests in a given amount of time ("rate limiting"). A Retry-After header might be included to this response indicating how long to wait before making a new request.

haofanwang avatar Feb 02 '21 03:02 haofanwang

Not a solution for this issue, but perhaps it is helpful for you guys. I ended up using transformer based Neural Translation https://github.com/UKPLab/EasyNMT

It takes more time, but since it is a pre-trained model it is not dependent on some API we have no control over and the translation quality is fantastic.

jonas-nothnagel avatar Feb 02 '21 08:02 jonas-nothnagel

@jonas-nothnagel, thanks for letting us know.

haofanwang avatar Feb 02 '21 08:02 haofanwang

So I found a workaround:

translator = Translator()
translator.raise_Exception = True
try:
    trans_obj = translator.translate(word_to_translate, src='he', dest=lang)
except Exception as err:
    translator = Translator()
    translator.raise_Exception = True
    trans_obj = translator.translate(word_to_translate, src='he', dest=lang)

So when the exception is thrown I start a new object and try again. Worked for me.

reinerstone avatar Jul 20 '21 00:07 reinerstone