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...

1 Answer 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

Sign up to request clarification or add additional context in comments.

2 Comments

I didn't have a pyodbcconf.pyd, but executing the first command worked - thanks!
I have error when run mt.exe c:\Python32\Lib\site-packages>"c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\mt.exe" -inputresource:c:\windows\syswow64\python32.dll;#2 -outputresource:pyodbc.pyd;#2 Microsoft (R) Manifest Tool version 6.1.7716.0 Copyright (c) Microsoft Corporation 2009. All rights reserved. mt.exe : general error c101008c: Failed to read the manifest from the resource of file "c:\windows\syswow64\python32.dll". The system cannot find the file specified.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.