ananconda下執行nltk報錯解決辦法
阿新 • • 發佈:2019-01-10
報錯內容:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "E:\anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "E:/anaconda_workspace/myfirst_NLP.py", line 14, in <module>
for text in gutenberg.fileids():
File "E:\anaconda2\lib\site-packages\nltk\corpus\util.py", line 116, in __getattr__
self.__load()
File "E:\anaconda2\lib\site-packages\nltk\corpus\util.py", line 81, in __load
LookupError:
**********************************************************************
Resource u*corpora/gutenberg* not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
Searched in:
- *C:\\Users\\XXXXXX/nltk_data*
- *C:\\nltk_data*
- *D:\\nltk_data*
- *E:\\nltk_data*
- *C:\\Python26-B\\nltk_data*
- *C:\\Python26-B\\lib\\nltk_data*
- *C:\\Users\\XXXXX\\AppData\\Roaming\\nltk_data*
**********************************************************************
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "E:\anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "E:/anaconda_workspace/myfirst_NLP.py", line 14, in <module>
for text in gutenberg.fileids():
File "E:\anaconda2\lib\site-packages\nltk\corpus\util.py", line 116, in __getattr__
self.__load()
File "E:\anaconda2\lib\site-packages\nltk\corpus\util.py", line 81, in __load
except LookupError: raise e
**********************************************************************
Resource u*corpora/gutenberg* not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
Searched in:
- *C:\\Users\\XXXXXX/nltk_data*
- *C:\\nltk_data*
- *D:\\nltk_data*
- *E:\\nltk_data*
- *C:\\Python26-B\\nltk_data*
- *C:\\Python26-B\\lib\\nltk_data*
- *C:\\Users\\XXXXX\\AppData\\Roaming\\nltk_data*
**********************************************************************
解決方案:
這個報錯的意思就是他在以下這幾個路徑搜尋了nltk.book但是沒有東西,所以你需要把下載路徑設定成這些當中的任何一個,比如C:\nltk_data,或者你把下載好的包直接複製到那個資料夾下,再匯入就好了。
在終端輸入:
>>> import nltk
>>> nltk.download()
執行出現:
圖片:點選all,然後download下載就可以啦。