Search code examples
pythondjangoapachenltkwampserver

Django webapp (on an Wampserver) hangs indefintely when importing nltk in views.py


I've deployed the web app using Wampserver on a Windows Server 2012. When I import nltk in views.py, the web page refuses to load.

Add this WSGIApplicationGroup% {GLOBAL} in the Wampserver htpd.config configuration file as indicated in this post and part of the problem has been resolved, but now when running the application using nltk package, the browser shows Server Error (500)


Solution

  • As I indicated in the question, in the httpd.config file it is necessary to add:

    WSGIApplicationGroup %{GLOBAL} 
    

    Additional, in views.py it is necessary to indicate Apache the path where the nltk files are, which by default are in C:/Users/user_name/AppData/Roaming/nltk_data, like so:

    import nltk
    from nltk.tokenize import word_tokenize
    from nltk.corpus import stopwords
    nltk.data.path.append('C:/Users/user_name/AppData/Roaming/nltk_data/')