title: Gunicorn with Flask using wrong Python
body: <p>I'm trying to bootstrap a Flask app on a Gunicorn server. By putting the two tools' docs together, plus searching around on SO, this is what I have so far... but it's not quite working.</p>
  
  <p><strong>app.py</strong>:</p>
  
  <pre><code>from flask import Flask, render_template
  from flask.ext.sqlalchemy import SQLAlchemy
  from werkzeug.contrib.fixers import ProxyFix
  
  app = Flask(__name__)
  app.wsgi_app = ProxyFix(app.wsgi_app)
  db = SQLAlchemy(app)
  
  @app.route('/')
  def index():
      return render_template('index.html')
  </code></pre>
  
  <p><strong>what I ran</strong>:</p>
  
  <p>From the same directory as app.py,</p>
  
  <pre><code>gunicorn app:app
  </code></pre>
  
  <p>Even starting this small, I've missed something. The error message is not very helpful:</p>
  
  <blockquote>
    <p>2013-09-12 20:13:07 [11461] [INFO] Starting gunicorn 0.14.5<br>
    2013-09-12 20:13:07 [11461] [INFO] Listening at: <code>http://127.0.0.1:8000</code> (11461)<br>
    2013-09-12 20:13:07 [11461] [INFO] Using worker: sync<br>
    2013-09-12 20:13:07 [11528] [INFO] Booting worker with pid: 11528<br>
    2013-09-12 20:13:07 [11528] [INFO] Worker exiting (pid: 11528)<br>
    2013-09-12 20:13:08 [11461] [INFO] Shutting down: Master<br>
    2013-09-12 20:13:08 [11461] [INFO] Reason: Worker failed to boot.  </p>
  </blockquote>
  
  <p>By the way, I'm running this on a Debian Linux system. Many thanks in advance for your help!</p>
  
  <p><strong>Update</strong> </p>
  
  <p>After turning on debugging, I got some more instructive error messages. This has become a very specific problem very fast: <code>ImportError: No module named flask</code>. Usually I get this sort of error when I'm not using my virtualenv--but I am. And upon closer inspection, Gunicorn seems to be using a different version of Python than my virtualenv uses, that is Python3. So... my particular python seems not to be getting used. How do I fix this, and tell Gunicorn to use the right Python?</p>