2

I'm trying to get Django to run through mod_wsgi on Apache2.22 but I'm getting an internal 500 error. I know there are other questions for this, but they don't have my specific error. Here is my traceback:

[Sat Jun 16 02:17:48 2012] [info] [client 128.227.11.143] mod_wsgi (pid=23071, process='partender', application='www.***.com|'): Loading WSGI script '/usr/home/***.com/zpencerq/part/apache/django.wsgi'.
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143] mod_wsgi (pid=23071): Target WSGI script '/usr/home/***.com/zpencerq/part/apache/django.wsgi' cannot be loaded as Python module.
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143] mod_wsgi (pid=23071): Exception occurred processing WSGI script '/usr/home/***.com/zpencerq/part/apache/django.wsgi'.
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143] Traceback (most recent call last):
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]   File "/usr/home/partender.myprotosite.com/zpencerq/part/apache/django.wsgi", line 9, in <module>
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]     import django.core.handlers.wsgi
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 2, in <module>
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]     from threading import Lock
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]   File "/usr/local/lib/python2.7/threading.py", line 15, in <module>
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]     from collections import deque
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]   File "/usr/local/lib/python2.7/collections.py", line 9, in <module>
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143]     from operator import itemgetter as _itemgetter
[Sat Jun 16 02:17:48 2012] [error] [client 128.227.11.143] ImportError: /usr/local/lib/python2.7/lib-dynload/operator.so: Undefined symbol "_PyUnicodeUCS4_AsDefaultEncodedString"

it seems to be an issue with python but I have no idea what to do with that last error in the traceback. is that a problem with the python install? I have done the simple WSGI hello world app, and that works perfectly fine. It's an issue with makign the django call.

I used 'ldd' on mod_wsgi.so and got the following output:

root@blah# ldd mod_wsgi.so
mod_wsgi.so:
ldd: mod_wsgi.so: Shared object "mod_wsgi.so" not found, required by "ldd"
mod_wsgi.so: exit status 1
5
  • For reference, 'ldd' should be run on the mod_wsgi.so in your Apache installation. IOW, give a full path or be in the same directory. See code.google.com/p/modwsgi/wiki/… Commented Jun 17, 2012 at 1:26
  • I was in the same directory. I'm taking that response as mod_wsgi.so is using a Python static library rather than shared. Commented Jun 17, 2012 at 16:42
  • No such thing. It says ldd could not find a file called mod_wsgi.so in the directory you were in. If it was statically linked it would still generate output but not show dependency on libpythonX.Y.so. Commented Jun 17, 2012 at 23:11
  • you were right. apparently i did something wrong though i'm pretty sure i did pwd and was in the current directory root@seese# ldd /usr/local/apache/modules/mod_wsgi.so /usr/local/apache/modules/mod_wsgi.so: libutil.so.7 => /lib/libutil.so.7 (0x2817d000) libm.so.5 => /lib/libm.so.5 (0x2818a000) libc.so.7 => /lib/libc.so.7 (0x28080000) Commented Jun 18, 2012 at 20:08
  • Graham, this question has been solved. I created a new question about further issues with WSGI and Django here: stackoverflow.com/questions/11092089/… Commented Jun 18, 2012 at 22:37

1 Answer 1

2

Most likely your mod_wsgi is compiled against one Python installation but you are trying to force it to use a different Python installation. The reason you are having a problem is because one Python installation was compiled with UCS2 support and the other UCS4.

Use 'ldd' on mod_wsgi.so to show what Python installation it is trying to use and then provide that information as part of question along with mod_wsgi configuration or WSGI script contents where you are trying to force it to use different Python installation, or incompatible virtual environment.

Sign up to request clarification or add additional context in comments.

1 Comment

This specific issue was due to an incompatible version of Python vs what mod_wsgi3 was compiled for! (running 2.7.2, mod_wsgi3 was compiled for 2.7.3) thanks! i may have another question soon and will post it separately. just wanted to say thanks Graham! i see you're like the main guy to answer many of these django/wsgi questions and also found your guide somewhere!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.