title: Mod_wsgi syntax error: "Invalid command import"
body: <p>i'm trying to setup mod_wsgi to serve my django media files (i want to use this also in a developement env)</p>
  
  <p>I followed <a href="https://code.djangoproject.com/wiki/django_apache_and_mod_wsgi" rel="nofollow">this guide</a> to correctly setup mod_wsgi.</p>
  
  <p>This is my wsgi file ("django.wsgi")</p>
  
  <pre><code>import os, sys
  
  path = '/home/smau/Workspace/Maynard/tothego_frontend/'
  if path not in sys.path:
      sys.path.append(path)
  
  #Calculate the path based on the location of the WSGI script.
  apache_configuration= os.path.dirname(__file__)
  project = os.path.dirname(apache_configuration)
  workspace = os.path.dirname(project)
  sys.path.append(workspace)
  
  os.environ['DJANGO_SETTINGS_MODULE'] = 'tothego_frontend.settings' 
  
  import django.core.handlers.wsgi
  application = django.core.handlers.wsgi.WSGIHandler()
  </code></pre>
  
  <p>This is my conf file ("django.conf")</p>
  
  <pre><code>Alias /site_media/ "/home/smau/Workspace/Maynard/tothego_frontend/site_media/"
  &lt;Directory "/home/smau/Workspace/Maynard/tothego_frontend/site_media"&gt;
  Order allow,deny
  Options Indexes
  Allow from all
  IndexOptions FancyIndexing
  &lt;/Directory&gt;
  
  WSGIScriptAlias / "/home/smau/Workspace/Maynard/tothego_frontend/srv/mod_wsgi/django.wsgi"
  
  &lt;Directory "/home/smau/Workspace/Maynard/tothego_frontend/srv/mod_wsgi"&gt;
  Allow from all
  &lt;/Directory&gt;
  </code></pre>
  
  <p>This is my "httpd.conf"</p>
  
  <pre><code>Include /home/smau/Workspace/Maynard/tothego_frontend/srv/mod_wsgi/django.wsgi
  </code></pre>
  
  <p>Everything seems to be like the guide, however, when i try to start/restart apache i get this error</p>
  
  <pre><code>root@archimedes:/etc/apache2# /etc/init.d/apache2 restart
  Syntax error on line 1 of /home/smau/Workspace/Maynard/tothego_frontend/srv/mod_wsgi/django.wsgi:
  Invalid command 'import', perhaps misspelled or defined by a module not included in the server configuration
  Action 'configtest' failed.
  The Apache error log may have more information.
     ...fail!
  </code></pre>
  
  <p>This is /var/log/apache2.log</p>
  
  <pre><code>[Thu Jul 14 11:39:31 2011] [notice] Apache/2.2.17 (Ubuntu) PHP/5.3.5-1ubuntu7.2 
  with Suhosin-Patch mod_wsgi/3.3 Python/2.7.1+ configured -- resuming normal operations
  
  [Thu Jul 14 11:44:28 2011] [notice] caught SIGTERM, shutting down
  PHP Warning:  PHP Startup: Unable to load dynamic library 
  '/usr/lib/php5/20090626/gd.so'- /usr/lib/php5/20090626/gd.so: cannot open shared object file: 
  No such file or directory in Unknown on line 0
  </code></pre>
  
  <p>The log doesn't seem (to me...) anyhow related to my problem. Why do i keep getting the "import" error? Did i give you enought information or do you need something else? I guess my pythonpath is correct:</p>