I can't use the nltk wordnet lemmatizer because I can't download the wordnet corpus on my university computer due to access rights issues.

I get the following error when I try to do so:

Resource 'corpora/wordnet' not found. Please use the NLTK Downloader
to obtain the resource: >>> nltk.download() Searched in:
    - '/home/XX/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'

When I had the same issue at home, I could resolve it by two ways:

  1. Using nltk.download(), the standard way and
  2. Creating a new folder at location /home/XX/nltk_data and just pasting the corpus directory inside it.

Now at the university I only have access to /home/XX/bin and not /home/XX directly. So is there anyway I could paste the wordnet corpus into /home/XX/bin and then somehow make nltk look for the corpus in that folder?

3 Answers 3

import nltk;

Now, nltk.data.path is a list of locations where to search for the modules. You can just do:

nltk.data.path.append("your location/directory");
  • 2
    Do we need to do this one time or everytime we run the script?
    – psr
    Sep 8, 2016 at 9:39

It seems that you need to set the environment variable "NLTK_DATA" to tell NLTK where to look. http://nltk.org/data.html


I solved the problems editing the pyinstaller nltk-hook. After much research, I decided to go it alone in the code structure. I solved my problem by commenting on the lines:


'''for p in nltk.data.path: datas.append((p, "nltk_data"))'''

hiddenimports = ["nltk.chunk.named_entity"]

What's more, you need to rename the file: pyi_rth__nltk.cpython-36.pyc to pyi_rth_nltk.cpython-36.pyc . This file have 1 more underline. Warning with the python version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.