Windows + Django + mod_wsgi = "DLL load failed"

Posted by Kyle MacFarlane on Server Fault See other posts from Server Fault or by Kyle MacFarlane
Published on 2010-09-13T14:21:30Z Indexed on 2011/01/05 10:55 UTC
Read the original article Hit count: 234

Filed under:
|
|

For a long time I was using Python 2.5 to do all this fine but recently upgraded to 2.7 since building stuff for 2.5 is a real pain. I also updated mod_wsgi to 3.3 for Python 2.7.

Everything is working fine with Apache + mod_wsgi on CentOS and also in the Django runserver on both Windows and CentOS, but not with Apache + mod_wsgi on Windows.

Whenever I try to access a page in my Django app I get the following (note that Apache starts fine):

ImportError at /
DLL load failed: The specified module could not be found.

Which is caused by things like:

from Crypto.Cipher import AES

Etree and others cause the exact same error and it is not limited to any specific packages. Anything with pyd files fails.

Googling around suggests reinstalling Python "for all users", but the installer doesn't give you that option anymore anyway. For good measure I've tried reinstalling Python 2.7 as an administrator and also told it to register itself as the default version of Python but neither helped.

I think the solution might have something to do with:

  1. The fact that I have 2.5, 2.6 and 2.7 installed on this machine and mod_wsgi might be loading the DLLs for 2.5 instead of 2.7.
  2. Something to do with WSGIPythonPath, which I usually don't need to set.

© Server Fault or respective owner

Related posts about Windows

Related posts about python