Ask Your Question

How can I fix requests.exceptions.HTTPError: 404 Client Error: Not Found for google_trans_new?

asked 2023-04-25 19:47:03 +0000

wagner gravatar image

updated 2023-04-26 14:21:47 +0000

I am getting the error below when trying to translate a text with google_trans_new in Python:

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/googletransnew/", line 189, in translate r.raiseforstatus() File "/usr/lib/python3/dist-packages/requests/", line 943, in raiseforstatus raise HTTPError(httperrormsg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https:// translate .google .cn/_/TranslateWebserverUi/data/batchexecute

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 9, in <module> translation = translator.translate(text, langtgt=targetlanguage) File "/usr/local/lib/python3.10/dist-packages/googletransnew/", line 194, in translate raise googlenewtransError(tts=self, response=r) googletransnew.googletransnew.googlenewtransError: 404 (Not Found) from TTS API. Probable cause: Unknown

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-04-25 19:49:27 +0000

wagner gravatar image

updated 2023-04-26 14:34:27 +0000

It turned out that the following patch fixes the problem. If you installed the package via git, you need implement the changes directly in the in your Python site-packages location:

After applying the fix you can translate a text like follows:

from google_trans_new import google_translator

# Text to translate
text = "Hello, how are you?"

target_language = "es"
translator = google_translator()
translation = translator.translate(text, lang_tgt=target_language)

print(f"Original text: {text}")
print(f"Translation: {translation}")
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools

1 follower


Asked: 2023-04-25 19:47:03 +0000

Seen: 37 times

Last updated: Apr 26