title: ImportError executing wsgi script within Apache
body: <p>I've written a little Flask web app. I've configured it in Apache2 Ubuntu on my local machine, and it works under Apache.</p>
  <p>Deploying to the remote server (Ubuntu/Apache2), the wsgi script fails with a ImportError</p>
  <p>However, from the command line, executing the wsgi file does not create an error condition.    Here's the error from the log, followed by an manual execution of the wsgi script:</p>
  <p>[wsgi:error] [pid 414495] [client 174.52.77.157:51364] ImportError: No module named lakesidepy.app</p>
  <pre><code>root@localhost:/var/www/lakesidepy# ./lakesidepy.wsgi
  root@localhost:/var/www/lakesidepy# 
  </code></pre>
  <p>This is the wsgi file:</p>
  <pre><code>#!/usr/bin/python3
  import sys
  sys.path.insert(0,&quot;/var/www/&quot;)
  from lakesidepy.app import app as application
  </code></pre>
  <p>This is the apache config:</p>
  <pre><code>&lt;VirtualHost *:80&gt;
    ServerName lakesidepy
    DocumentRoot /var/www/lakesidepy
    HostNameLookups off
    WSGIDaemonProcess lakesidepy user=www-data group=www-data threads=5
    WSGIScriptAlias / /var/www/lakesidepy/lakesidepy.wsgi
  &lt;/VirtualHost&gt;
  </code></pre>
  <p>the lakesidepy dir:</p>
  <pre><code>total 44
  drwxr-xr-x  5 duane duane  4096 May 22 03:32 .
  drwxrwsr-x 13 duane duane  4096 May 22 03:05 ..
  -rwxr-xr-x  1 duane duane  3993 May 20 00:52 app.py
  -rwxr-xr-x  1 duane duane   107 May 22 03:32 lakesidepy.wsgi
  -rw-r--r--  1 root  root  12288 May 19 01:11 .lakesidepy.wsgi.swp
  drwxr-xr-x  2 duane duane  4096 May 22 03:31 __pycache__
  drwxr-xr-x  2 duane duane  4096 May 18 23:36 static
  drwxr-xr-x  2 duane duane  4096 May 18 23:36 templates
  -rw-r--r--  1 duane duane   285 May 22 02:53 test_script.py
  duane@localhost:/var/www/lakesidepy$ 
  </code></pre>
  <p>Snippet  from app.py:</p>
  <pre><code>from flask import Flask
  .
  .
  .
  
  app = Flask(__name__)
  
  @app.route(&quot;/&quot;)
  def input():
      return render_template('input.html')
  ...
  </code></pre>