title: Target WSGI script cannot be loaded as Python module - Flask
body: <p>I am trying to open the website in my browser at the appropriate IP address and I get a 500 internal sever error. I am using Digital Ocean and an Ubuntu 14.04 server with apache2. After I get the 500 error I run</p>
  
  <pre><code>$ tail -f /var/log/apache2/error.log
  </code></pre>
  
  <p>and then I get the following</p>
  
  <pre><code>    user@crimemap:~# tail -f /var/log/apache2/error.log
      [Sun May 01 11:32:48.811666 2016] [:error] [pid        14833:did 140337753298688] [remote    
      71.97.193.235:2804]  mod_wsgi (pid=14833): Target WSGI script '/var/www/crimemap/crimemap.wsgi' cannot 
      be loaded as Python module.
      [Sun May 01 11:32:48.811718 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804]
      mod_wsgi (pid=14833): Exception occurred processing WSGI script '/var/www/crimemap/crimemap.wsgi'.
      [Sun May 01 11:32:48.811749 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804] 
      Traceback (most recent call last):
      [Sun May 01 11:32:48.811788 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804]   
      File "/var/www/crimemap/crimemap.wsgi", line 3, in &lt;module&gt;
      [Sun May 01 11:32:48.811830 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804]     
      from crimemap import app as application
      [Sun May 01 11:32:48.811845 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804]   
      File   "/var/www/crimemap/crimemap.py", line 1, in &lt;module&gt;
      [Sun May 01 11:32:48.811900 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804]     
      from dbhelper import DBHelper
      [Sun May 01 11:32:48.811914 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804]   
      File "/var/www/crimemap/dbhelper.py", line 1, in &lt;module&gt;
      [Sun May 01 11:32:48.811932 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804]     
      import pymysql
      [Sun May 01 11:32:48.811958 2016] [:error] [pid 14833:tid 140337753298688] [remote 71.97.193.235:2804] 
      ImportError: No module named pymysql
  </code></pre>
  
  <p>So then I run</p>
  
  <pre><code>user@crimemap:~# /var/www/crimemap/crimemap.wsgi
  </code></pre>
  
  <p>and get</p>
  
  <pre><code>/var/www/crimemap/crimemap.wsgi: line 1: import: command not found
  /var/www/crimemap/crimemap.wsgi: line 2: syntax error near unexpected token `0,'
  /var/www/crimemap/crimemap.wsgi: line 2: `sys.path.insert(0, "/var/www/crimemap")'
  </code></pre>
  
  <p>I have looked around and can't figure out the syntax error?</p>
  
  <p>This is what crimemap.wsgi looks like.</p>
  
  <pre><code>import sys
  sys.path.insert(0, "/var/www/crimemap")
  from crimemap import app as application
  </code></pre>
  
  <p>Also when I import for pymysql or the other .py files I get no errors?</p>
  
  <pre><code>user@crimemap:~# python
  Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
  [GCC 4.8.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import pymysql
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>I have tried adding a shebang line and python path to the wsgi file to make sure it was executable. Nothing. Made sure default files where not interfering, nothing. I'm pretty new to this so it could be a completely idiotic solution. If so I apologize but I have looked everywhere.</p>