pythonimporterror-handling

Resource punkt not found. Please use the NLTK Downloader to obtain the resource: >>> import nltk >>> nltk.download('punkt')


I have NLTK installed and it is going me error 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/PY3/english.pickle

Searched in: - '/Users/divyanshundley/nltk_data' - '/Library/Frameworks/Python.framework/Versions/3.10/nltk_data' - '/Library/Frameworks/Python.framework/Versions/3.10/share/nltk_data' - '/Library/Frameworks/Python.framework/Versions/3.10/lib/nltk_data' - '/usr/share/nltk_data' - '/usr/local/share/nltk_data' - '/usr/lib/nltk_data' - '/usr/local/lib/nltk_data' - ''


and my code is

import nltk
nltk.download('punkt')

def tokenize(token):
    return nltk.word_tokenize(token);
tokenize("why is this not working?");

Solution

  • Please download the below also. This will resolve your issue:

    nltk.download('punkt')
    nltk.download('wordnet')
    nltk.download('omw-1.4')