Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: Unexpected status code 429 #8

Open
jonas-nothnagel opened this issue Jan 13, 2021 · 9 comments
Open

Exception: Unexpected status code 429 #8

jonas-nothnagel opened this issue Jan 13, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@jonas-nothnagel
Copy link

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

@Saravananslb
Copy link
Owner

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 saravananslb2015@gmail.com
I will help you this issue.

@Saravananslb Saravananslb self-assigned this Jan 13, 2021
@Saravananslb Saravananslb added the bug Something isn't working label Jan 13, 2021
@Saravananslb Saravananslb pinned this issue Jan 13, 2021
@jonas-nothnagel
Copy link
Author

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.

@JSMboli
Copy link

JSMboli commented Jan 22, 2021

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.

@Saravananslb
Copy link
Owner

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

@jonas-nothnagel
Copy link
Author

@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.

@haofanwang
Copy link

haofanwang commented Feb 2, 2021

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.

@jonas-nothnagel
Copy link
Author

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.

@haofanwang
Copy link

@jonas-nothnagel, thanks for letting us know.

@reinerstone
Copy link

reinerstone commented Jul 20, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants