title: Flask - WSGI - No module named 'flask'
body: <p>I've been following Sentdex' Flask tutorial. He's using a Venv to set up his Flask, but didn't set his Python up to work with a Venv. I've tried installing Flask globally - yet it still doesn't work. Trying to browse to the server returns a 500 Internal Server Error</p>
  
  <p>I'm getting the usual <code>no module named flask</code>error.</p>
  
  <p><strong>errorFGL.log</strong></p>
  
  <pre><code>[Sun Feb 05 11:22:32.043925 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] mod_wsgi (pid=26340): Target WSGI script '/var/www-fgl/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module.
  [Sun Feb 05 11:22:32.044105 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] mod_wsgi (pid=26340): Exception occurred processing WSGI script '/var/www-fgl/FlaskApp/flaskapp.wsgi'.
  [Sun Feb 05 11:22:32.044243 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] Traceback (most recent call last):
  [Sun Feb 05 11:22:32.045011 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814]   File "/var/www-fgl/FlaskApp/flaskapp.wsgi", line 8, in &lt;module&gt;
  [Sun Feb 05 11:22:32.045070 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814]     from FlaskApp import app as application
  [Sun Feb 05 11:22:32.045549 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814]   File "/var/www-fgl/FlaskApp/FlaskApp/__init__.py", line 1, in &lt;module&gt;
  [Sun Feb 05 11:22:32.045594 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814]     from flask import Flask
  [Sun Feb 05 11:22:32.045689 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] ImportError: No module named 'flask'
  </code></pre>
  
  <p><strong>__init__.py</strong></p>
  
  <pre><code>from flask import Flask
  
  app = Flask(__name__)
  
  @app.route('/')
  def homepage():
      return "Success"
  
  if __name__ == "__main__":
      app.run()
  </code></pre>
  
  <p><strong>flaskapp.wsgi</strong></p>
  
  <pre><code>#!/usr/bin/python
  import sys
  import logging
  logging.basicConfig(stream=sys.stderr)
  
  sys.path.insert(0,"/var/www-fgl/FlaskApp/")
  
  from FlaskApp import app as application
  application.secret_key = '[REDACTED]'
  </code></pre>
  
  <p><strong>fgl-database.conf</strong></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          ServerName [REDACTED]
          WSGIScriptAlias / /var/www-fgl/FlaskApp/flaskapp.wsgi
          &lt;Directory /var/www-fgl&gt;
              Require all granted
          &lt;/Directory&gt;
          Alias /static /var/www-fgl/FlaskApp/FlaskApp/static
          &lt;Directory /var/www-fgl/FlaskApp/FlaskApp/static/&gt;
              Require all granted
          &lt;/Directory&gt;
          ErrorLog ${APACHE_LOG_DIR}/errorFGL.log
          LogLevel warn
          CustomLog ${APACHE_LOG_DIR}/accessFGL.log combined
  
  
  
  
  &lt;/VirtualHost&gt;
  </code></pre>