[英]"HTTPError: HTTP Error 404: Not Found" while using translation function in TextBlob
When I try to use translate function in TextBlob library in jupyter notebook, I get:当我尝试在 jupyter notebook 的 TextBlob 库中使用翻译功能时,我得到:
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.当我第一次运行完全相同的代码时,这段代码在 5-6 天前运行良好,但之后每当我运行这段代码时,它都会给我同样的错误消息。 I have been trying to run this code since last 4-5 days but it never worked again.自过去 4-5 天以来,我一直在尝试运行此代码,但它再也没有工作过。
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.我是 stackoverflow 的新手,在这个平台上提出了我的第一个问题,所以如果我的问题没有遵循这个平台的规则,请原谅我。
Textblob library uses Google API for translation functionality in the backend. Textblob 库在后端使用 Google API 来实现翻译功能。 Google has made some changes in the its API recently. Google 最近对其 API 进行了一些更改。 Due to this reason TextBlob's translation feature has stopped working.由于这个原因,TextBlob 的翻译功能已停止工作。 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:我注意到,通过对 translate.py 文件(在所有 TextBlob 文件所在的文件夹中)进行一些小的更改,如下所述,我们可以消除此错误:
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:将 translate.py 中的上述代码更改为以下内容:
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"
I have just tried this.我刚刚试过这个。 It did not work for me the first times.第一次对我不起作用。
I restarted the Anaconda Prompt, restarted IPython.我重新启动了 Anaconda Prompt,重新启动了 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:我使用的是 Windows 10,我不使用虚拟环境,更改的两个文件是:
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.而且我还发现我必须对换行符进行制表符缩进。
It's fixed at https://github.com/sloria/TextBlob/pull/398它固定在https://github.com/sloria/TextBlob/pull/398
You should use a tag version with that fix.您应该使用带有该修复程序的标记版本。
# requirements/txt
textblob @ git+https://github.com/sloria/TextBlob@0.17.1#=textBlob
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.