title: Flask and Apache2: No module named app
body: <p>I'm trying to deploy <strong>Flask</strong> app via Apache2 but I'm getting <code>No module named app</code> error. I'm also using <code>virtualenv</code></p>
  
  <p><strong>planer(Flask app)</strong></p>
  
  <pre><code>(venv)jdoe@jdoe-virtual-machine:/var/www/planer$ la
  app.py   forms.py   .git        helpers.py   __init__.py  main.pyc   models.pyc   README.md         setup.cfg  templates  views.py
  app.pyc  forms.pyc  .gitignore  helpers.pyc  main.py      models.py  planer.wsgi  requirements.txt  static     venv       views.pyc
  </code></pre>
  
  <p><strong>planer.conf</strong></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          ServerName planer.dev
          ServerAdmin admin@mywebsite.com
          WSGIScriptAlias / /var/www/planer/planer.wsgi
          &lt;Directory /var/www/planer/planer/&gt;
              Order allow,deny
              Allow from all
          &lt;/Directory&gt;
          Alias /static /var/www/planer/static
          &lt;Directory /var/www/planer/static/&gt;
              Order allow,deny
              Allow from all
          &lt;/Directory&gt;
          ErrorLog ${APACHE_LOG_DIR}/error.log
          LogLevel warn
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>planer.wsgi</strong></p>
  
  <pre><code>import sys, os
  sys.path.insert (0,'/var/www/planer')
  
      sys.path = [
          '/var/www/planer/venv/lib/python2.7/lib-dynload',
          '/usr/lib/python2.7',
      ]
  
      activate_this = '/var/www/planer/venv/bin/activate_this.py'
      execfile(activate_this, dict(__file__=activate_this))
  
      import app as application
  </code></pre>
  
  <p><strong>error</strong></p>
  
  <pre><code>[Wed Jan 06 09:45:29.781102 2016] [:error] [pid 20727] [client 127.0.0.1:42448] mod_wsgi (pid=20727): Target WSGI script '/var/www/planer/planer.wsgi' cannot be loaded as Python module.
  [Wed Jan 06 09:45:29.781137 2016] [:error] [pid 20727] [client 127.0.0.1:42448] mod_wsgi (pid=20727): Exception occurred processing WSGI script '/var/www/planer/planer.wsgi'.
  [Wed Jan 06 09:45:29.781208 2016] [:error] [pid 20727] [client 127.0.0.1:42448] Traceback (most recent call last):
  [Wed Jan 06 09:45:29.781235 2016] [:error] [pid 20727] [client 127.0.0.1:42448]   File "/var/www/planer/planer.wsgi", line 12, in &lt;module&gt;
  [Wed Jan 06 09:45:29.781302 2016] [:error] [pid 20727] [client 127.0.0.1:42448]     import app as application
  [Wed Jan 06 09:45:29.781327 2016] [:error] [pid 20727] [client 127.0.0.1:42448] ImportError: No module named app
  </code></pre>