Ask coding questions

← Back to all posts
Problem installing and using NLTK library - Python

I have installed the NLTK library to process some text. So I want to get the number of tokens/words of a list of texts.
To do that, I first imported word_tokenize using:

from nltk.tokenize import word_tokenize
Then I ran the following lines of code:
content = list(sms['message'])

At this point, I'm getting the following error which I don't know how to solve :(.

I am new using so I would really appreciate your help.

The error says: Resource punkt not found.
Please use the NLTK Downloader to obtain the resource:

how do I do that from the console in


Hello where you able to do this program because right now I was also struging with the same error.


Solved! I typed import nltk in the console and then I typed'punkt') as it was suggested in the error message. It worked fine when I ran the code again. Thanks