title: Flask, mod_wsgi, and Apache: ImportError
body: <p>I'm getting this in my error logs:</p>
  
  <blockquote>
    <p>ImportError: No module named flask</p>
  </blockquote>
  
  <p>It looks exactly like in <a href="https://stackoverflow.com/questions/5841531/django-mod-wsgi-apache-importerror-at-no-module-named-djproj-urls">Django + mod_wsgi + apache: ImportError at / No module named djproj.urls</a>, but I tried that solution, and it doesn't seem to work... I am correctly inserting the app home and parent folder into the system path, but this error is still coming up.</p>
  
  <p>Navigating to my page still brings up the 500 page.</p>
  
  <p>More information: I'm using <a href="http://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud" rel="nofollow noreferrer">Amazon EC2</a> free tier, with Apache in the form of httpd. Everything is installed correctly, I'm pretty sure...</p>
  
  <p>Here's my stuff (app name <em>badassery</em> and app home folder name <em>hatemail</em> - I change my mind a lot):</p>
  
  <p>Error log</p>
  
  <pre><code>[Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] mod_wsgi (pid=28143): Target WSGI script '/home/ec2-user/hatemail/badassery.wsgi' cannot be loaded as Python module.
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] mod_wsgi (pid=28143): Exception occurred processing WSGI script '/home/ec2-user/hatemail/badassery.wsgi'.
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] Traceback (most recent call last):
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]   File "/home/ec2-user/hatemail/badassery.wsgi", line 6, in &lt;module&gt;
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]     from badassery import app as application
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]   File "/home/ec2-user/hatemail/badassery.py", line 6, in &lt;module&gt;
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]     from flask import Flask, request, session, url_for, redirect, render_template, abort, g, flash, _app_ctx_stack
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] ImportError: No module named flask
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] mod_wsgi (pid=28143): Target WSGI script '/home/ec2-user/hatemail/badassery.wsgi' cannot be loaded as Python module.
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] mod_wsgi (pid=28143): Exception occurred processing WSGI script '/home/ec2-user/hatemail/badassery.wsgi'.
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] Traceback (most recent call last):
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]   File "/home/ec2-user/hatemail/badassery.wsgi", line 6, in &lt;module&gt;
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]     from badassery import app as application
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]   File "/home/ec2-user/hatemail/badassery.py", line 6, in &lt;module&gt;
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148]     from flask import Flask, request, session, url_for, redirect, render_template, abort, g, flash, _app_ctx_stack
  [Sun Nov 11 07:14:45 2012] [error] [client 18.189.71.148] ImportError: No module named flask
  </code></pre>
  
  <h3>badassery.wsgi</h3>
  
  <pre><code>import sys
  
  sys.path.insert(0,'/home/ec2-user/hatemail')
  sys.path.insert(1,'/home/ec2-user')
  
  from badassery import app as application
  </code></pre>
  
  <p>Additions to the httpd.conf file</p>
  
  <pre><code>WSGISocketPrefix /var/run/wsgi
  
  &lt;VirtualHost *:80&gt;
          ServerName 54.243.61.41
          DocumentRoot "/home/ec2-user/hatemail"
  
          WSGIDaemonProcess badassery user=apache group=apache processes=1 threads=5
          WSGIScriptAlias / /home/ec2-user/hatemail/badassery.wsgi
          WSGIScriptReloading On
  
          &lt;Directory /home/ec2-user/hatemail&gt;
                  WSGIProcessGroup badassery
                  WSGIApplicationGroup %{GLOBAL}
                  Order deny,allow
                  Allow from all
          &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Directory structure</p>
  
  <pre><code>~
      hatemail
          badassery.py
          badassery.wsgi
          Procfile
          README
          requirements.txt
          schema.sql
          static/
          templates/
          venv/bin/activate
  </code></pre>
  
  <p>Yes, I am doing "if <strong>name</strong> == 'main': app.run()".</p>
  
  <p>How can I fix this problem?</p>