title: Unable to load a Python package via a file
body: <p>I am trying to load a file having these contents:</p>
  
  <pre><code>import os, sys
  sys.path.append('/opt/graphite/webapp')
  os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
  
  import django.core.handlers.wsgi
  
  application = django.core.handlers.wsgi.WSGIHandler()
  </code></pre>
  
  <p>I keep getting this error:</p>
  
  <pre><code>Target WSGI script '/opt/graphite/conf/graphite.wsgi' cannot be loaded as Python module.
  </code></pre>
  
  <p>When I bring up Python on the command line and try to load this module as follows, I get no error:</p>
  
  <pre><code>import django.core.handlers.wsgi
  </code></pre>
  
  <p>I checked the permissions for django and all its subdirectories. Any ideas?</p>
  
  <p>These are the errors in apache:</p>
  
  <pre><code>Thu Aug 20 14:37:23 2015] [info] [client 26.16.7.183] mod_wsgi (pid=1812, process='graphite', application=''): Loading WSGI script '/opt/graphite/conf/graphite.wsgi'.
  [Thu Aug 20 14:37:23 2015] [error] [client 26.16.7.183] mod_wsgi (pid=1812): Target WSGI script '/opt/graphite/conf/graphite.wsgi' cannot be loaded as Python module.
  [Thu Aug 20 14:37:23 2015] [error] [client 26.16.7.183] mod_wsgi (pid=1812): Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi'.
  [Thu Aug 20 14:37:23 2015] [error] [client 26.16.7.183] Traceback (most recent call last):
  [Thu Aug 20 14:37:23 2015] [error] [client 26.16.7.183]   File "/opt/graphite/conf/graphite.wsgi", line 5, in &lt;module&gt;
  [Thu Aug 20 14:37:23 2015] [error] [client 26.16.7.183]     import django.core.handlers.wsgi
  [Thu Aug 20 14:37:23 2015] [error] [client 26.16.7.183] ImportError: No module named django.core.handlers.wsgi
  [Thu Aug 20 14:37:23 2015] [debug] mod_headers.c(743): headers: ap_headers_output_filter()
  </code></pre>
  
  <p>this is my graphite.conf for apache:</p>
  
  <p>================</p>
  
  <pre><code>Listen 8090
  LoadModule wsgi_module /usr/lib64/apache2/mod_wsgi.so
  WSGISocketPrefix /etc/apache2/wsgi
  &lt;Directory /opt/graphite/webapp&gt;
          Options All
          AllowOverride All
          Order deny,allow
          Allow from all
  &lt;/Directory&gt;
  DocumentRoot "/opt/graphite/webapp"
  #
  &lt;VirtualHost *:8090&gt;
          ServerName 192.168.101.2
          Header set Access-Control-Allow-Origin "*"
          DocumentRoot "/opt/graphite/webapp"
          WSGIDaemonProcess graphite processes=20 threads=20 display-name='%{GROUP}' inactivity-timeout=120
          WSGIProcessGroup graphite
  #
          WSGIApplicationGroup %{GLOBAL}
          WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
          WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
          Alias /static/ /opt/graphite/webapp/content/
          &lt;Location "/content/"&gt;
                   SetHandler None
          &lt;/Location&gt;
  #
          Alias /media/ "/usr/local/lib64/python2.6/site-packages/django/contrib/admin/media/"
  #
          &lt;Location "/media/"&gt;
                   SetHandler None
          &lt;/Location&gt;
          &lt;Directory /opt/graphite/conf/&gt;
             Allow from all
          &lt;/Directory&gt;
  #
  LogLevel debug
  ErrorLog /var/log/apache2/graphite_error
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>It keeps giving me error about this file: </p>
  
  <pre><code>/opt/graphite/conf/graphite.wsgi
  
  [Fri Aug 21 13:04:52 2015] [info] [client 29.0.213.18] mod_wsgi (pid=11626, process='graphite', application=''): Loading WSGI script '/opt/graphite/conf/graphite.wsgi'.
  [Fri Aug 21 13:04:52 2015] [error] [client 29.0.213.18] mod_wsgi (pid=11626): Target WSGI script '/opt/graphite/conf/graphite.wsgi' cannot be loaded as Python module.
  [Fri Aug 21 13:04:52 2015] [error] [client 29.0.213.18] mod_wsgi (pid=11626): Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi'.
  </code></pre>
  
  <p>when I am on the shell and issue:</p>
  
  <pre><code>python /opt/graphite/conf/graphite.wsgi
  </code></pre>
  
  <p>I get no error. Not sure what the problem here?</p>