Updated answer:NLTK works for 2.7 well. I had 3.2. I uninstalled 3.2 and installed 2.7. Now it works!!
I have installed NLTK and tried to download NLTK Data. What I did was to follow the instrution on this site: http://www.nltk.org/data.html
I downloaded NLTK, installed it, and then tried to run the following code:
>>> import nltk
>>> nltk.download()
It gave me the error message like below:
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
nltk.download()
AttributeError: 'module' object has no attribute 'download'
Directory of C:\Python32\Lib\site-packages
Tried both nltk.download()
and nltk.downloader()
, both gave me error messages.
Then I used help(nltk)
to pull out the package, it shows the following info:
NAME
nltk
PACKAGE CONTENTS
align
app (package)
book
ccg (package)
chat (package)
chunk (package)
classify (package)
cluster (package)
collocations
corpus (package)
data
decorators
downloader
draw (package)
examples (package)
featstruct
grammar
help
inference (package)
internals
lazyimport
metrics (package)
misc (package)
model (package)
parse (package)
probability
sem (package)
sourcedstring
stem (package)
tag (package)
test (package)
text
tokenize (package)
toolbox
tree
treetransforms
util
yamltags
FILE
c:\python32\lib\site-packages\nltk
I do see Downloader there, not sure why it does not work. Python 3.2.2, system Windows vista.
If you are running a really old version of nltk, then there is indeed no download module available (reference)
Try this:
As per the reference, anything after 0.9.5 should be fine
Try
nltk.download('all')
this will download all the data, no need to download individually
you should add python to your PATH during installation of python...after installation.. open cmd prompt type command-
pip install nltk
then go to IDLE and open a new file..save it as file.py..then open file.py type the following: import nltkTL;DR
To download a particular dataset/models, use the
nltk.download()
function, e.g. if you are looking to download thepunkt
sentence tokenizer, use:If you're unsure of which data/model you need, you can start out with the basic list of data + models with:
It will download a list of "popular" resources, these includes:
EDITED
In case anyone is avoiding errors from downloading larger datasets from
nltk
, from https://stackoverflow.com/a/38135306/610569Updated
From v3.2.5, NLTK has a more informative error message when
nltk_data
resource is not found, e.g.:Related
To find
nltk_data
directory (auto-magically), see https://stackoverflow.com/a/36383314/610569To download
nltk_data
to a different path, see https://stackoverflow.com/a/48634212/610569To config
nltk_data
path (i.e. set a different path for NLTK to findnltk_data
), see https://stackoverflow.com/a/22987374/610569I think you must have named the file as nltk.py (or the folder consists of a file with that name) so change it to any other name and try executing it....
This worked for me: