运行nltk示例 Resource u'tokenizers punkt english.pickle' not found解决

时间:2023-06-29 13:18:32

nltk安装完毕后,编写如下示例程序并运行,报Resource u'tokenizers/punkt/english.pickle' not found错误

import nltk

sentence = """At eight o'clock on Thursday morning Arthur didn't feel very good."""
tokens = nltk.word_tokenize(sentence)
print(tokens)

解决方法:
编写如下程序并运行,有代理情况下配置代理,运行成功后弹出NLTK Downloader,下载所有包后再次运行示例程序结果正常

import nltk
nltk.set_proxy("**.com:8080","username","password")
nltk.download()