What if the download of nltk.download () fails
This article mainly shows you the "nltk.download () download failure how to do", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "nltk.download () download failure how to do" this article.
Install nltk
Pip install nltk
After installation, report an error
> > 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 ", line 1, in 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'****
The reason is that you need to nltk.download () to download the dataset.
# change the download directory nltk.download (download_dir=r'D:\ soft\ python3.6\ share\ nltk_data')
Try: nltk.download (), but:
So go to the official website to download: https://github.com/nltk/nltk_data.
Just download packages and put it in the directory where the error was reported, and remember to rename packages to nltk_data here.
The above is all the contents of the article "what to do if the nltk.download () download fails". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!