[英]Python pandas HTTPError:“ HTTP Error 404: Not Found” when using pandas import function for Kenneth French Data Library
[英]"HTTPError: HTTP Error 404: Not Found" while using translation function in TextBlob
當我嘗試在 jupyter notebook 的 TextBlob 庫中使用翻譯功能時,我得到:
HTTPError: HTTP Error 404: Not Found
我已經發布了我的代碼和錯誤消息的屏幕截圖以供參考。 當我第一次運行完全相同的代碼時,這段代碼在 5-6 天前運行良好,但之后每當我運行這段代碼時,它都會給我同樣的錯誤消息。 自過去 4-5 天以來,我一直在嘗試運行此代碼,但它再也沒有工作過。
我的代碼:
from textblob import TextBlob
en_blob = TextBlob('Simplilearn is one of the world’s leading certification training providers.')
en_blob.translate(to='es')
我是 stackoverflow 的新手,在這個平台上提出了我的第一個問題,所以如果我的問題沒有遵循這個平台的規則,請原諒我。
Textblob 庫在后端使用 Google API 來實現翻譯功能。 Google 最近對其 API 進行了一些更改。 由於這個原因,TextBlob 的翻譯功能已停止工作。 我注意到,通過對 translate.py 文件(在所有 TextBlob 文件所在的文件夾中)進行一些小的更改,如下所述,我們可以消除此錯誤:
原始代碼:
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"
將 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"
我剛剛試過這個。 第一次對我不起作用。
我重新啟動了 Anaconda Prompt,重新啟動了 IPython。 並重新運行我的代碼段,修復后問題就消失了。 我使用的是 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
而且我還發現我必須對換行符進行制表符縮進。
它固定在https://github.com/sloria/TextBlob/pull/398
您應該使用帶有該修復程序的標記版本。
# requirements/txt
textblob @ git+https://github.com/sloria/TextBlob@0.17.1#=textBlob
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.