Not had any problems implementing this set up before, got a new server set up at home and wanted to work on some django projects.

Im using virtualenv with virtualenvwrapper, mod_wsgi module seems to be installed correctly. here is the vhost im using

<VirtualHost *:80>
        ServerName local.projectname.com
        ServerAlias local.projectname.co.uk

        WSGIDaemonProcess site-dev1 user=mike group=mike threads=20 python-path=/home/mike/envs/projectenv/lib/python2.6/site-packages
        WSGIProcessGroup site-dev1
        WSGIScriptAlias / /home/mike/Sites/path/project/django.wsgi

        <Directory /home/mike/Sites/path/project>
                Options +Indexes FollowSymLinks +ExecCGI
                AllowOverride AuthConfig FileInfo
                Order allow,deny
                Allow from all

        # Allow cross domain @font-face styles for Firefox
        <FilesMatch "\.(ttf|otf|eot)$">
                <IfModule mod_headers.c>
                        Header set Access-Control-Allow-Origin "*"

        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined

When try to navigate to the project i get 500 internal server error, heres the out put from the apache error logs

[Sun Jul 24 08:46:32 2011] [error] [client] Traceback (most recent call last):
[Sun Jul 24 08:46:32 2011] [error] [client]   File "/home/mike/Sites/outsideline/queenonline/queenonline.wsgi", line 16, in <module>
[Sun Jul 24 08:46:32 2011] [error] [client]     from django.core.handlers.wsgi import WSGIHandler
[Sun Jul 24 08:46:32 2011] [error] [client] ImportError: No module named django.core.handlers.wsgi

I can import from django.core.handlers.wsgi import WSGIHandler in shell with out any errors, As i understand it the process and group of the WSGIdaemon should be the user and group owners of the files, i have also set my apache user and group to run as mike:mike to see if that would work

Im totally out of ideas now so if anyone can shed some light on this i will be eternally grateful!

  • Anyone got any ideas " – Mike Waites Jul 24 '11 at 18:08
  • When you have imported Django in the shell, what do you get for 'django.__file__'. This will tell you location of where Django is installed. – Graham Dumpleton Jul 24 '11 at 23:49


To debug this problem you can output logging output from your .wsgi script to a file using a logger (Python logger). PYTHONPATH can be read inside Python using sys.path

  import sys
  log = open("/tmp/log.txt", "wt") # ghetto logging
  print >> log, sys.path # you'll see what you have PYTHONPATH when running the script

Then you can check if Python can actually open the file

  import sys
  log = open("/tmp/log.txt", "wt") # ghetto logging
      f = open("/path/to/django/__init__.py", "rt")
  exception Exception, e:
      print >> log, str(e)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.