Ask coding questions

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

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'])
tokens=word_tokenize(str(content))

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

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

https://storage.googleapis.com/replit/images/1553561995028_e10601336b4353291b8a55065671a2f3.pn

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 repl.it?

Comments
hotnewtop
LORENZOMINJARES

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

[deleted]

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