Trying to use NLTK with Python and run it on Pythonanywhere

Viewed 32

I have created a chatbot using NLTK together with Python Flask that runs fine on my local Windows environment. When I deploy my code to Pythonanywhere I run into problems with the NLTK data. The error shows that it cannot find the wordnet.zip file:

Resource #033[93mwordnet#033[0m not found.
  Please use the NLTK Downloader to obtain the resource:
**NO MATCH**
  #033[31m>>> import nltk
  >>> nltk.download('wordnet')
  #033[0m
  For more information see: https://www.nltk.org/data.html
**NO MATCH**
  Attempted to load #033[93mcorpora/wordnet.zip/wordnet/#033[0m
**NO MATCH**
  *Searched in:
    - '**/home/vvephl2/nltk_data**'*

But the wordnet data is available at the given directory... see directory with wordnet.zip file

Until now I've tried:

  • Unzip wordnet.zip in dir corpora

  • Put wordnet.zip in dir nltk_data

  • Unzip wordnet.zip in dir nltk_data

  • re-install wordnet (nltk.download('wordnet'))

  • run tests using NLTK in Python interpreter; runs fine!!!

  • veryfied the NLTK configuration, looks fine

    import nltk nltk.data.path ['/home/vvephl2/nltk_data', '/usr/local/nltk_data', '/usr/local/share/nltk_data', '/usr/local/lib/nltk_data', '/usr/share/nltk_data', '/usr/local/sh are/nltk_data', '/usr/lib/nltk_data', '/usr/local/lib/nltk_data']

What can I do to make the code on Pythonanywhere find the NLTK (wordnet) data??

Regards, Jos

0 Answers
Related