这篇文章主要为大家展示了“nltk.download()下载失败怎么办”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“nltk.download()下载失败怎么办”这篇文章吧。
安装nltk
pip install nltk
安装完之后,报错
>>> from nltk.corpus import brown >>> brown.words() Traceback (most recent call last): File "D:\soft\python3.6\lib\site-packages\nltk\corpus\util.py", line 80, in __load try: root = nltk.data.find('{}/{}'.format(self.subdir, zip_name)) File "D:\soft\python3.6\lib\site-packages\nltk\data.py", line 675, in find raise LookupError(resource_not_found) LookupError: ********************************************************************** Resource [93mbrown[0m not found. Please use the NLTK Downloader to obtain the resource: [31m>>> import nltk >>> nltk.download('brown') [0m Searched in: - 'C:\\Users\\WYXCz/nltk_data' - 'C:\\nltk_data' - 'D:\\nltk_data' - 'E:\\nltk_data' - 'D:\\soft\\python3.6\\nltk_data' - 'D:\\soft\\python3.6\\share\\nltk_data' - 'D:\\soft\\python3.6\\lib\\nltk_data' - 'C:\\Users\\WYXCz\\AppData\\Roaming\\nltk_data' ********************************************************************** During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "D:\soft\python3.6\lib\site-packages\nltk\corpus\util.py", line 116, in __getattr__ self.__load() File "D:\soft\python3.6\lib\site-packages\nltk\corpus\util.py", line 81, in __load except LookupError: raise e File "D:\soft\python3.6\lib\site-packages\nltk\corpus\util.py", line 78, in __load root = nltk.data.find('{}/{}'.format(self.subdir, self.__name)) File "D:\soft\python3.6\lib\site-packages\nltk\data.py", line 675, in find raise LookupError(resource_not_found) LookupError: ********************************************************************** Resource [93mbrown[0m not found. Please use the NLTK Downloader to obtain the resource: [31m>>> import nltk >>> nltk.download('brown') [0m Searched in: - 'C:\\Users\\WYXCz/nltk_data' - 'C:\\nltk_data' - 'D:\\nltk_data' - 'E:\\nltk_data' - 'D:\\soft\\python3.6\\nltk_data' - 'D:\\soft\\python3.6\\share\\nltk_data' - 'D:\\soft\\python3.6\\lib\\nltk_data' - 'C:\\Users\\WYXCz\\AppData\\Roaming\\nltk_data' **********************************************************************
原因是需要执行nltk.download()
下载数据集
# 更改下载目录 nltk.download(download_dir=r'D:\soft\python3.6\share\nltk_data')
又试: nltk.download(),but:
于是去官网直接下载:https://github.com/nltk/nltk_data。
下载packages就好,放入之前报错中的目录,记得这里将 packages 重命名成 nltk_data。
以上是“nltk.download()下载失败怎么办”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。