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

6.9k views Asked by At

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.

3

There are 3 answers

2
Terry On BEST ANSWER

Move files:

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

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

to

"C:\Python27"

Hope it helps.

0
HamzDiou On

For those who installed pywin32 via pip : check that you have done it outside a virtualenv.

If you've done it inside virtualenv, we can get this kind of error.

Prefer binarie installation : See Mark Amery response here

0
tonyprr On

Install pywin32-218.win32-py2.7.exe in machines of 32 or 64 bits.