Getting 405 error while trying to download nltk data

南楼画角 提交于 2019-11-26 17:12:24

问题


When i try the below code

python -c "import nltk; nltk.download('punkt'); 
nltk.download('averaged_perceptron_tagger'); 
nltk.download('maxent_treebank_pos_tagger'); 
nltk.download('wordnet')"

the console says

[nltk_data] Error loading punkt: HTTP Error 405: Not allowed.
[nltk_data] Error loading averaged_perceptron_tagger: HTTP Error 405:
[nltk_data]     Not allowed.
[nltk_data] Error loading maxent_treebank_pos_tagger: HTTP Error 405:
[nltk_data]     Not allowed.
[nltk_data] Error loading wordnet: HTTP Error 405: Not allowed.

回答1:


This is caused by a down-age of Github raw file link.

Meanwhile a stop-gap solution would be to manually download the file:

PATH_TO_NLTK_DATA=/home/username/nltk_data/
wget https://github.com/nltk/nltk_data/archive/gh-pages.zip
unzip gh-pages.zip
mv nltk_data-gh-pages/ $PATH_TO_NLTK_DATA

We're working on finding an alternative to the data and model downloading.

Meanwhile, @everyone please help to check that your script(s) and make sure that you're not overloading the data downloads! Thank you in advance!!

Please check https://github.com/nltk/nltk/issues/1787 for latest updates on this issue.




回答2:


For MacOSX - small modification to the above answer:

PATH_TO_NLTK_DATA=~/nltk_data/
wget https://github.com/nltk/nltk_data/archive/gh-pages.zip
unzip gh-pages.zip
mv nltk_data-gh-pages/packages/ $PATH_TO_NLTK_DATA

Note that this is a big download (~700MB).



来源:https://stackoverflow.com/questions/45318066/getting-405-error-while-trying-to-download-nltk-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!