title: Flask WSGI application hangs when import nltk
body: <p>I followed the instructions <a href="https://beagle.whoi.edu/redmine/projects/ibt/wiki/Deploying_Flask_Apps_with_Apache_and_Mod_WSGI" rel="nofollow noreferrer">here</a> to create a onefile flask-app deployed to apache2 with mod-wsgi on ubuntu. That all works fine when using the original flask app. However, when adding <em>import nltk</em> to the flask app apache hangs (no 500).</p>
  
  <p>I use python 2.7 and nltk 2.0.4</p>
  
  <p><a href="https://stackoverflow.com/questions/4236045/django-apache-mod-wsgi-hangs-on-importing-a-python-module-from-so-file">Others</a> seem to have had similar problems with other packages. Setting </p>
  
  <pre><code>WSGIApplicationGroup %{GLOBAL}
  </code></pre>
  
  <p>in the VirtualHost configuration seemed to have helped. However, I still get the same behavior. Did anybody run into the same issue? Thanks for the help!</p>
  
  <p>Here is the VirtualHost Configuration file:</p>
  
  <pre><code>&lt;VirtualHost *:8080&gt;
  
      # ---- Configure VirtualHost Defaults ----
  
      ServerAdmin jsmith@whoi.edu 
  
      DocumentRoot /home/bitnami/public_html/http
  
      &lt;Directory /&gt;
              Options FollowSymLinks
              AllowOverride None
      &lt;/Directory&gt;
  
      &lt;Directory /home/bitnami/public_html/http/&gt;
              Options Indexes FollowSymLinks MultiViews
              AllowOverride None
              Order allow,deny
              Allow from all
      &lt;/Directory&gt;
  
      # ---- Configure WSGI Listener(s) ----
  
      WSGIDaemonProcess flaskapp user=www-data group=www-data processes=1 threads=5
      WSGIScriptAlias /flasktest1 /home/bitnami/public_html/wsgi/flasktest1.wsgi 
  
      &lt;Directory /home/bitnami/public_html/http/flasktest1&gt;
              WSGIProcessGroup flaskapp
              WSGIApplicationGroup %{GLOBAL}
              Order deny,allow
              Allow from all
      &lt;/Directory&gt;
  
      # ---- Configure Logging ----
  
  ErrorLog /home/bitnami/public_html/logs/error.log
  LogLevel warn
  CustomLog /home/bitnami/public_html/logs/access.log combined
  </code></pre>
  
  <p></p>
  
  <p>Here is the modified flask code</p>
  
  <pre><code>#!/usr/bin/python
  from flask import Flask
  
  import nltk
  app = Flask(__name__)
  @app.route('/')
  def home():
      return """&lt;html&gt;
      &lt;h2&gt;Hello from Test Application 1&lt;/h2&gt;
      &lt;/html&gt;"""
  
  @app.route('/&lt;foo&gt;')
  def foo(foo):
      return """&lt;html&gt;
      &lt;h2&gt;Test Application 1&lt;/2&gt;
      &lt;h3&gt;/%s&lt;/h3&gt;
      &lt;/html&gt;""" % foo
  
  if __name__ == '__main__':
      "Are we in the __main__ scope? Start test server."
      app.run(host='0.0.0.0',port=5000,debug=True)
  </code></pre>