5

Previously I have been trying to host multiple DEMO django projects using a virtual host on apache, and have been successfully with the help of stackoverflow.

Now I have been trying to host my new project using the same technique like the previous ones. My new project is connected to the sql_server database. My project runs perfectly when using djangos in-built server.

When i try running using apache i get an 500 Internal Server Error and my apache error logs shows -

Exception occurred processing WSGI script 

ImproperlyConfigured: Error loading pyodbc module: DLL load failed: A dynamic link library (DLL) initialization routine failed.

My wsgi file looks like this -

import os
import sys

path = 'C:/path/project1'
if path not in sys.path:
    sys.path.append(path)

os.environ["DJANGO_SETTINGS_MODULE"] = "settings"

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

And i do have "C:\Windows\SysWOW64\python27.dll" in my machine

My system - Windows 7, Apache 2.2, python 2.7, django 1.4.2

Another info i found out on my machine - Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32

Any solution towards this??

Thanks alot guys...

4

1 に答える 1

4

I managed to solve this problem, after spending severl hours googling for answers, finally found an answer here, and it says :

It appears that this dependency is being satisfied by running inside of python.exe (which is linked against the same). When the dll version of the python interpreter is instead hosted by another process, the windows sxs configuration applies the msvcr90 dependency only to the python dll.

This means that, in general, pyodbc.pyd (and likely pyodbcconf.pyd) will be unusable in embedded python on windows unless the host application is linked against the appropriate version of the msvc runtimes.

Use mt.exe (a freely available tool in the windows sdk) and try the commands on the command line.

Where do I get mt.exe?

mt.exe -inputresource:c:\windows\syswow64\python27.dll;#2 -outputresource:pyodbc.pyd;#2

mt.exe -inputresource:c:\windows\syswow64\python27.dll;#2 -outputresource:pyodbcconf.pyd;#2

Hopefully this wil be usefull for someone.

Cheers

于 2012-12-10T14:42:17.350 に答える