- 一、异常展示:
- 二、异常出现原因
- 三、解决方案
- 3.1 下载`punkt.zip`
- 3.2 新建目录 nltk_data
- 四、测试异常是否解决
D:CODEInterpreterpython3.6.8python.exe D:/CODEFile/PythonCode01/PyTorch/ChatRobot/2/NLTK.py [nltk_data] Error loading punkt:二、异常出现原因Traceback (most recent call last): File "D:/CODEFile/PythonCode01/PyTorch/ChatRobot/2/NLTK.py", line 7, in tokens = nltk.word_tokenize(sentence) File "D:CODEInterpreterpython3.6.8libsite-packagesnltktokenize__init__.py", line 129, in word_tokenize sentences = [text] if preserve_line else sent_tokenize(text, language) File "D:CODEInterpreterpython3.6.8libsite-packagesnltktokenize__init__.py", line 106, in sent_tokenize tokenizer = load(f"tokenizers/punkt/{language}.pickle") File "D:CODEInterpreterpython3.6.8libsite-packagesnltkdata.py", line 750, in load opened_resource = _open(resource_url) File "D:CODEInterpreterpython3.6.8libsite-packagesnltkdata.py", line 876, in _open return find(path_, path + [""]).open() File "D:CODEInterpreterpython3.6.8libsite-packagesnltkdata.py", line 583, in find raise LookupError(resource_not_found) LookupError: ********************************************************************** Resource punkt not found. Please use the NLTK Downloader to obtain the resource: >>> import nltk >>> nltk.download('punkt') For more information see: https://www.nltk.org/data.html Attempted to load tokenizers/punkt/english.pickle Searched in: - 'C:\Users\Administrator/nltk_data' - 'D:\CODEInterpreter\python3.6.8\nltk_data' - 'D:\CODEInterpreter\python3.6.8\share\nltk_data' - 'D:\CODEInterpreter\python3.6.8\lib\nltk_data' - 'C:\Users\Administrator\AppData\Roaming\nltk_data' - 'C:\nltk_data' - 'D:\nltk_data' - 'E:\nltk_data' - '' **********************************************************************
NLK是自然语言处理的官方库,Python上著名的自然语言处理库自带语料库,词性分类库自带分类,分词,等等功能。
********************************************************************** Resource punkt not found. Please use the NLTK Downloader to obtain the resource:
没有找到 punkt 资源包。
Searched in:
- 'C:\Users\Administrator/nltk_data'
- 'D:\CODEInterpreter\python3.6.8\nltk_data'
- 'D:\CODEInterpreter\python3.6.8\share\nltk_data'
- 'D:\CODEInterpreter\python3.6.8\lib\nltk_data'
- 'C:\Users\Administrator\AppData\Roaming\nltk_data'
- 'C:\nltk_data'
- 'D:\nltk_data'
- 'E:\nltk_data'
- ''
搜索 punkt 资源包 在这些路径下查找过,但是没有找到。
链接: https://pan.baidu.com/s/1H2qBy16qwLdDG_eTOQzlCg 提取码: rajj
3.2 新建目录 nltk_data任意选取一个路径:
创建目录 nltk_data,进入nltk_data,创建子目录 tokennizers,解压压缩包
【注意路径的层次,否则会失败】
异常已经解决OK!!!



