But wordnet IS installed

1,762 views
Skip to first unread message

Peter Bengtsson

unread,
Apr 12, 2009, 4:26:37 PM4/12/09
to nltk-users
I'm getting this traceback:
File "/home/django/kl/search/views.py", line 559, in
_get_variations_wordnet
if not wordnet.morphy(each):

File "/usr/lib/python2.5/site-packages/nltk-0.9.8-py2.5.egg/nltk/
corpus/util.py", line 68, in __getattr__
self.__load()

File "/usr/lib/python2.5/site-packages/nltk-0.9.8-py2.5.egg/nltk/
corpus/util.py", line 56, in __load
except LookupError: raise e

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

root@peterbe2:~# python -m nltk.downloader wordnet
[nltk_data] Downloading package 'wordnet' to /root/nltk_data...
[nltk_data] Package wordnet is already up-to-date!


I've also successfully run:
# python -m nltk.downloader all
...
[nltk_data] Done downloading collection 'all'

How can I debug what's gone wrong? This is a Ubuntu server with python
2.5.

Edward Loper

unread,
Apr 12, 2009, 4:54:03 PM4/12/09
to nltk-...@googlegroups.com
From this:

> root@peterbe2:~# python -m nltk.downloader wordnet
> [nltk_data] Downloading package 'wordnet' to /root/nltk_data...

It looks like the downloader is saving the package to root's home
directory, rather than to any system directory. Then when you try to
access it as a user (django), it's looking in that user's home
directory, not root's.

The intent was that it should install to system directories if
possible (i.e., if they're writable); and to the current user's home
directory as a last resort. But it looks like there's a bug that's
currently making it check the current user's home directory *first*,
which isn't really what you want if the current user is root.

The short-term fix is to explicitly tell nltk where to download things
to: E.g.:

>>> nltk.download('wordnet', '/usr/share/nltk_data')

I'll try to put in a more long-term fix in svn sometime today or tomorrow.

-Edward

Peter Bengtsson

unread,
Apr 12, 2009, 7:35:15 PM4/12/09
to nltk-users
Thanks. I ended up just installing it a second time as the user
running the django.

The result can be seen here:
http://crosstips.org/variationstester/
It's actually not only NLTK.
Reply all
Reply to author
Forward
0 new messages