pywintypes27.dll not found using Apache, Django, pywin32, Python2.7 and mod_wsgi

Terry picture Terry · Oct 13, 2011 · Viewed 6.9k times · Source

I have a Django application using django-mssql to communicate w/ SQL Server.

This works just fine in the dev server (runserver) but under Apache/mod-wsgi, I get a error related to it trying to find a .dll which does exist:

Exception Type: ImportError
Exception Value:    No system module 'pywintypes' (pywintypes27.dll)
Exception Location: C:\Python27\lib\site-packages\win32\lib\pywintypes.py in __import_pywin32_system_module__, line 98
Python Executable:  C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe

I used ActivePython2.7.2, mod_wsgi, pywin32 Build 216 and Django1.3.1, all of 32 bits

pywintypes27.dll exists in C:\Windows\SysWOW64 instead of C:\Windows\System32 as expected in my 64 bit windows 7

Thanks in advance

This is the same question as django-mssql not working in Apache w/ mod-wsgi, but works fine in dev server but that answer didn't help me cause I have installed 32 bits pywin32, I am new to stackoverflow and hope it is right to ask as a new question rather than hijack people's thread.

Answer

Terry picture Terry · Oct 14, 2011

Move files:

  • pythoncom27.dll
  • pythoncomloader27.dll
  • pywintypes27.dll

from "C:\Python27\Lib\site-packages\pywin32_system32"

to

"C:\Python27"

Hope it helps.