1

I am using Django 1.5.3, Python 2.7.3 and Apache 2.2 with mod_wsgi on Windows and i have the following Nltk loading problem:

File "C:\\Users\\Christos\\workspace\\djangolesson\\question_handling.py", line 11, in  
     <module> stop_words = corpus.stopwords.words('english')
File "C:\\Python27\\lib\\site-packages\\nltk\\corpus\\util.py", line 68, in __getattr__
     self.__load()
File "C:\\Python27\\lib\\site-packages\\nltk\\corpus\\util.py", line 56, in __load
     except LookupError: raise e
LookupError: 
**********************************************************************
Resource 'corpora/stopwords' not found.  Please use the NLTK
Downloader to obtain the resource:  >>> nltk.download()
   Searched in:
     - 'C:\\\\Windows\\\\system32\\\\config\\\\systemprofile/nltk_data'
     - 'C:\\\\nltk_data'
     - 'D:\\\\nltk_data'
     - 'E:\\\\nltk_data'
     - 'C:\\\\Python27\\\\nltk_data'
     - 'C:\\\\Python27\\\\lib\\\\nltk_data'
     - 'C:\\\\Windows\\\\system32\\\\config\\\\systemprofile\\\\AppData\\\\Roaming\\\\nltk_data'
**********************************************************************

from apaches' error.log, for any nltk module, while loading it from a shell, or even running the same .py file doesn't raise any problems and it works fine. Others have had the same problem, but i couldn't find a solution. Thanks in advance

#

Thanks to @codeape i have found a solution: I reinstalled nltk in C:\Python27\nltk_data and it works.

user2120596
  • 35
  • 1
  • 4
  • Post you code and a full traceback - not only the last message. – ElmoVanKielmo Apr 04 '14 at 08:04
  • will you please paste traceback? – Nilesh Apr 04 '14 at 08:04
  • Where is your nltk_data directory located? By default, nltk looks in directories from the NLTK_DATA environment variable, as well as c:\nltk_data, d:\nltk_data and e:\nltk_data and others. Take a look at the code in file nltk/data.py, the function find(resource_name) raises the exception. – codeape Apr 04 '14 at 08:10
  • the problem is that it works running the code from the shell – user2120596 Apr 04 '14 at 08:14
  • 1
    Yes, but still: Where is your ntlk_data directory located? Figure that out, then check that your apache2/mod_wsgi process has read access to that directory. – codeape Apr 04 '14 at 08:15
  • My nltk_data folder is in: 'C:\Users\User1\AppData\Roaming\nltk_data'. How do i get that directory now accessible from nltk? @codeape – user2120596 Apr 04 '14 at 08:23

0 Answers0