Python中使用NLTK库报错:raise LookupError(resource_not_found)

showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml
Traceback (most recent call last):
  File "questions.py", line 202, in 
    main()
  File "questions.py", line 26, in main
    for filename in files
  File "questions.py", line 26, in 
    for filename in files
  File "questions.py", line 88, in tokenize
    tokens = nltk.tokenize.word_tokenize(document.lower())
  File "D:\python36\lib\site-packages\nltk\tokenize\__init__.py", line 129, in word_tokenize
    sentences = [text] if preserve_line else sent_tokenize(text, language)
  File "D:\python36\lib\site-packages\nltk\tokenize\__init__.py", line 106, in sent_tokenize
    tokenizer = load("tokenizers/punkt/{0}.pickle".format(language))
  File "D:\python36\lib\site-packages\nltk\data.py", line 752, in load
    opened_resource = _open(resource_url)
  File "D:\python36\lib\site-packages\nltk\data.py", line 877, in _open
    return find(path_, path + [""]).open()
  File "D:\python36\lib\site-packages\nltk\data.py", line 585, in find
    raise LookupError(resource_not_found)
LookupError:
**********************************************************************
  Resource ?[93mpunkt?[0m not found.
  Please use the NLTK Downloader to obtain the resource:

  ?[31m>>> import nltk
  >>> nltk.download('punkt')
  ?[0m
  For more information see: https://www.nltk.org/data.html

  Attempted to load ?[93mtokenizers/punkt/english.pickle?[0m

  Searched in:
    - 'C:\\Users\\Administrator/nltk_data'
    - 'D:\\python36\\nltk_data'
    - 'D:\\python36\\share\\nltk_data'
    - 'D:\\python36\\lib\\nltk_data'
    - 'C:\\Users\\Administrator\\AppData\\Roaming\\nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
    - ''

Python中使用NLTK库报错:raise LookupError(resource_not_found)_第1张图片

可能提示的不一样, 在导入nlkt下面添加它提示这个就行,下载一个不行,继续下载它提示的,例如:

import nlkt
nltk.download('punkt')

或者

 nltk.download()
 弹出界面,下载所有
 参考: [https://blog.csdn.net/haoaiqian/article/details/70233454](https://blog.csdn.net/haoaiqian/article/details/70233454)

你可能感兴趣的:(python,数据分析)