title: How to solve import errors while trying to deploy Flask using WSGI on Apache2
body: <p>I am having an issue deploying a flask app on apache2 using wsgi. I have posted the error logs and config files below. I have tried moving things around, renaming them, etc, but all give me an internal server error. Not sure why I'm getting the import error. Any input / suggestions are appreciated, thanks!</p>
  
  <p>Here is my apache error.log</p>
  
  <pre><code>[Sun Sep 12 20:47:59 2010] [error] [client] mod_wsgi (pid=9753): Target WSGI script '/sites/flaskfirst/wsgi.py' cannot be loaded as Python module.
  [Sun Sep 12 20:47:59 2010] [error] [client] mod_wsgi (pid=9753): Exception occurred processing WSGI script '/sites/flaskfirst/wsgi.py'.
  [Sun Sep 12 20:47:59 2010] [error] [client] Traceback (most recent call last):
  [Sun Sep 12 20:47:59 2010] [error] [client]   File "/sites/flaskfirst/wsgi.py", line 1, in &lt;module&gt;
  [Sun Sep 12 20:47:59 2010] [error] [client]     from app import app as application
  [Sun Sep 12 20:47:59 2010] [error] [client] ImportError: No module named app
  </code></pre>
  
  <p>wsgi.py</p>
  
  <pre><code># This is wsgi.py
  from app import app as application
  </code></pre>
  
  <p>app.py</p>
  
  <pre><code># This is app.py
  from flask import Flask, render_template
  import settings
  
  app = Flask(__name__)
  app.debug = settings.DEBUG
  
  from views.homepage import *
  from views.events import *
  from views.submit import *
  from views.feed import *
  
  if __name__ == "__main__":
      app.run()
  </code></pre>
  
  <p>Here is the basics of the directory tree, to give you an idea.</p>
  
  <pre><code>/flaskfirst/
      /static/
      /templates/
      /views/
      __init__.py
      app.py
      wsgi.py
  </code></pre>
  
  <p>Here is the apache virtualhost file</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          ServerAdmin sreustle@gmail.com
          ServerName crath.org
          DocumentRoot /sites/flaskfirst
  
          # WSGI Settings
          WSGIScriptAlias / /sites/flaskfirst/wsgi.py
          WSGIDaemonProcess flaskfirst user=sreustle group=general processes=1 threads=10
          WSGIProcessGroup flaskfirst
  
          # Static Directories
          Alias /static /sites/flaskfirst/static/
          &lt;Location "/static"&gt;
                  SetHandler None
          &lt;/Location&gt;
  
  &lt;/VirtualHost&gt;
  </code></pre>