Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.
share|improve this question
up vote 1 down vote accepted

A solution that worked for me that allowed me to use Python 2.7 (although not very desirable), is to build the Crypto module with MingGW. Download Crypto source package and run build --compiler=mingw32.

See this question for more information:

share|improve this answer
Heh, I just saw that it was your question on stackoverflow as well... – mandrake Jan 5 '11 at 10:20
I don't even remember asking this question on ServerFault. I never found a truly proper solution for msvcr90.dll and Apache but commenting out those lines at the StackOverflow link and rebuilding everything (even the official PIL) has worked fine for me. I recently had a very similar problem with lxml and libxml/libxslt/iconv but lxml is easy to setup for static linking if you read their docs. – Kyle MacFarlane Feb 14 '11 at 23:32

I ran into similar problems, which eventually appeared to be related to and also issue 4120 (new style of DLL hell).

Using Python 2.5 (the version before these bugs started) solved this for me. YMMV.

share|improve this answer
I wish I could accept two answers because that bug does seem to be heavily related. – Kyle MacFarlane Feb 14 '11 at 23:39

Your Answer


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.