0

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
Benbob
  • 277
  • 1
  • 6
  • 19
  • 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 04: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. – Benbob Nov 26 '10 at 04:40
  • Provided traceback above. Looks like functools may not be installed? – Benbob Nov 29 '10 at 00:27

2 Answers2

0

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

h3.
  • 189
  • 3
  • 9
0

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.

Benbob
  • 277
  • 1
  • 6
  • 19