Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have followed this guide to setup django on a cpanel server (CentOS 5.2) http://toic.org/2010/08/14/django-on-cpanel-with-python2-6-virtualenv-and-mod_wsgi/comment-page-1/#comment-680 I get a 500 page on the domain I've set up.

Apache Log:

 File "/home/myofirst/virtualenv/lib/python2.6/site-packages/Django-1.2.3-py2.6.egg/django/core/handlers/wsgi.py", line 1, in <module>
 File "/home/myofirst/djangosites/test1.wsgi", line 13, in <module>
 mod_wsgi (pid=20251): Exception occurred processing WSGI script '/home/myofirst/djangosites/test1.wsgi'.
 mod_wsgi (pid=20251): Target WSGI script '/home/myofirst/djangosites/test1.wsgi' cannot be loaded as Python module.

WSGI file:

import sys
import site
import os

vepath = '/home/myofirst/virtualenv/lib/python2.6/site-packages'
prev_sys_path = list(sys.path)
site.addsitedir(vepath)
sys.path.append('/home/myofirst/djangosites')
new_sys_path = [p for p in sys.path if p not in prev_sys_path]
for item in new_sys_path:
    sys.path.remove(item)
sys.path[:0] = new_sys_path
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'test1.settings'
application = WSGIHandler()

Seems to be crashing on this line:

from django.core.handlers.wsgi import WSGIHandler

Virtualenv path is correct so I'm not sure what would cause this.

edit I get this traceback when running the .wsgi file.

Traceback (most recent call last):
  File "djangosites/test1.wsgi", line 14, in <module>
    from django.core.handlers.wsgi import WSGIHandler
  File "/home/myofirst/virtualenv/lib/python2.6/site-packages/Django-1.2.3-py2.6.egg/django/core/handlers/wsgi.py", line 1, in <module>
    from threading import Lock
  File "/opt/python2.6/lib/python2.6/threading.py", line 13, in <module>
    from functools import wraps
ImportError: cannot import name wraps
share|improve this question
    
That cannot be the whole message from the Apache error log. Update your question with the full Python traceback that appears in the Apache error logs. The traceback should appear after the line 'Target WSGI script ... cannot be loaded as Python module.' –  Graham Dumpleton Nov 26 '10 at 4:24
    
That is what was in my apache log. Those 4 lines only. I have no idea why it isn't providing tracebacks. I can't seem to reproduce the problem from the python interpreter either. –  Keyo Nov 26 '10 at 4:40
    
Provided traceback above. Looks like functools may not be installed? –  Keyo Nov 29 '10 at 0:27

2 Answers 2

Is there a __init__.py file in the same folder than test1.wsgi ?

share|improve this answer
    
Nope. I've chmodded all the directories correctly and I'm still getting this. –  Keyo Nov 28 '10 at 23:36
    
I believe it wont work without an __init__.py –  h3. Nov 30 '10 at 0:15
up vote 0 down vote accepted

I changed LogLevel warn to LogLevel debug in the apache conf file. Django now loads, no errors in the logs, only lines indicating where a python process has been started.

I guess it's not really a good idea to hide errors, but I would expect debug to log more errors. Anyway it worked, and that's what is important.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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