title: My WSGI application cannot be loaded as Python module. What am I doing wrong
body: <p>I have been trying to get a WebAPI to run on the server. However I keep getting this error everytime I log into the site via the web browser</p>
  
  <blockquote>
    <p>Internal Server Error</p>
    
    <p>The server encountered an internal error or misconfiguration and was
    unable to complete your request.</p>
    
    <p>Please contact the server administrator, jordi.duch@gmail.com and
    inform them of the time the error occurred, and anything you might
    have done that may have caused the error.</p>
    
    <p>More information about this error may be available in the server error
    log. Apache/2.2.22 (Ubuntu) Server at complex.ffn.ub.es Port 80</p>
  </blockquote>
  
  <p>I check the error log file and I have the following. </p>
  
  <blockquote>
    <p>[Thu Jul 14 17:16:08 2016] [error] [client 161.116.80.82] mod_wsgi
    (pid=21450): Target WSGI script
    '/home/xarxes_ub/python_code/configure.wsgi' cannot be loaded as
    Python module.</p>
    
    <p>[Thu Jul 14 17:16:08 2016] [error] [client 161.116.80.82] mod_wsgi
    (pid=21450): Exception occurred processing WSGI script
    '/home/xarxes_ub/python_code/configure.wsgi'.</p>
    
    <p>[Thu Jul 14 17:16:08 2016] [error] [client 161.116.80.82] Traceback
    (most recent call last):</p>
    
    <p>[Thu Jul 14 17:16:08 2016] [error] [client 161.116.80.82]   File
    "/home/xarxes_ub/python_code/configure.wsgi", line 10, in </p>
    
    <p>[Thu Jul 14 17:16:08 2016] [error] [client 161.116.80.82]     from
    MenuUB2 import app as application</p>
    
    <p>[Thu Jul 14 17:16:08 2016] [error] [client 161.116.80.82] ImportError:
    No module named MenuUB2</p>
  </blockquote>
  
  <p>I configured my .wsgi file based on the directions given on this site
  <a href="http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/" rel="nofollow">http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/</a></p>
  
  <p>It mentions specifically "Keep in mind that you will have to actually install your application into the virtualenv as well. Alternatively there is the option to just patch the path in the .wsgi file before the import: <code>
  import sys
  sys.path.insert(0, '/path/to/the/application')</code>" Which is what I did </p>
  
  <p>Here is the configure.wsgi file</p>
  
  <pre><code>import sys
  sys.path.insert(0, '/home/xarxes_ub/python_code/MenuUB2.py')
  
  from MenuUB2 import app as application
  </code></pre>
  
  <p>In addition here is my apache configuration file that I edited. I highlighted the lines I added with ###.</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  
  DocumentRoot /var/www/web_del_grup/
  
  ################Added lines###############
      WSGIScriptAlias /submitFrame /home/xarxes_ub/python_code/configure.wsgi
  WSGIDaemonProcess MenuUB2 user=www-data group=www-data threads=5  
  ################Added lines###############  
  
  #####################Added Directory####################
  &lt;Directory /home/xarxes_ub/python_code&gt;
          WSGIScriptReloading On
      WSGIProcessGroup MenuUB2
          WSGIApplicationGroup %{GLOBAL}
          Order deny,allow
          Allow from all
   &lt;/Directory&gt;
  #####################Added Directory####################
  
  ErrorLog /var/log/apache2/error.log
  
  # Options -Indexes +FollowSymLinks MultiViews
  # RewriteEngine on
  # RewriteCond %{HTTP_REFERER} !^$
  # RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?complex.ffn.ub.edu [NC]
  # RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?complex.ffn.ub.es [NC]
  # RewriteRule ^/xarxesub/(.json)$ - [F,NC,L]
  
      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn
  
      CustomLog /var/log/apache2/access.log combined
  </code></pre>
  
  <p></p>
  
  <p>Please tell me what needs to be done. If I can get this to work I'd be so relieved. 
  Also note that I tried changing the "configure.wsgi" file to return a static and it works
  Example is here</p>
  
  <pre><code>def application(environ, start_response):
      status = '200 OK'
      output = 'Hello World!'
  
      response_headers = [('Content-type', 'text/plain'),
                          ('Content-Length', str(len(output)))]
  
     start_response(status, response_headers)
  
      return [output] 
  </code></pre>