1

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.
Kyle MacFarlane
  • 807
  • 2
  • 9
  • 12

2 Answers2

2

I ran into similar problems, which eventually appeared to be related to http://bugs.python.org/issue7833 and also issue 4120 (new style of DLL hell).

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

1

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 setup.py build --compiler=mingw32.

See this question for more information: https://stackoverflow.com/questions/3706293

mandrake
  • 124
  • 7
  • Heh, I just saw that it was your question on stackoverflow as well... – mandrake Jan 05 '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