4

When I try to use translate function in TextBlob library in jupyter notebook, I get:

HTTPError: HTTP Error 404: Not Found

I have posted my code and screenshot of error message for reference here. This code worked well 5-6 days ago when I ran exactly the same code first time but after that whenever I run this code it gives me the same error message. I have been trying to run this code since last 4-5 days but it never worked again.

My code:

from textblob import TextBlob

en_blob = TextBlob('Simplilearn is one of the world’s leading certification training providers.')

en_blob.translate(to='es')  

I am new to stackoverflow and asking my first question on this plateform so please pardon me if I my question is not following rules of this platform.

2
  • could you please add more verbose exception output (with traceback)? Commented Sep 26, 2021 at 22:42
  • 1
    I have finally found the solution to above problem after doing some googling and is posted below. Thanks for taking out your time to look into my question. Commented Sep 28, 2021 at 19:57

3 Answers 3

5

Textblob library uses Google API for translation functionality in the backend. Google has made some changes in the its API recently. Due to this reason TextBlob's translation feature has stopped working. I noticed that by making some minor changes in translate.py file (in your folder where all TextBlob files are located) as mentioned below, we can get rid of this error:

original code:

url = "http://translate.google.com/translate_a/t?client=webapp&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"

change above code in translate.py to following:

url = "http://translate.google.com/translate_a/t?client=te&format=html&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
Sign up to request clarification or add additional context in comments.

2 Comments

I just tried this, but I still get a HTTP Error 404: Not Found. Please advise
this link Still does not work in 2023
0

I have just tried this. It did not work for me the first times.

I restarted the Anaconda Prompt, restarted IPython. And re-ran my snippets and the problem go away after the fix. I am using Windows 10, I don't use virtual environment, the two files that were changed are:

C:\Users\behai\anaconda3\pkgs\textblob-0.15.3-py_0\site-packages\textblob\translate.py
C:\Users\behai\anaconda3\Lib\site-packages\textblob\translate.py

And I have also found that I have to do tab-indentation for the newline.

Added on 02/01/2021:

I did not do anything much at all. I applied the suggestion by Mr. Manish ( green tick above ). I had this 404 problem in the Anaconda environment. After applied the change above, I just restarted the "Anaconda Prompt (anaconda3)", and it worked.

This is the change as suggested above, in:

C:\Users\behai\anaconda3\Lib\site-packages\textblob\translate.py
    # url = "http://translate.google.com/translate_a/t?client=webapp&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
    url = "http://translate.google.com/translate_a/t?client=te&format=html&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"

The file below get auto-updated:

C:\Users\behai\anaconda3\pkgs\textblob-0.15.3-py_0\site-packages\textblob\translate.py

3 Comments

I'm not sure this really answers the question
Can you please elaborate further what you did and post clear solutions tried by you so that it can help others too.
Hi, I have updated my answer above with Added on 02/01/2021:. Thank you and best regards.
0

It's fixed at https://github.com/sloria/TextBlob/pull/398

You should use a tag version with that fix.

# requirements/txt
textblob @ git+https://github.com/sloria/[email protected]#=textBlob

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.