tanrj / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Can't import pyodbc when using mod_wsgi #126

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Use any wsgi-file (the wsgi-sample will do) and put "import pyodbc" on top of 
it.

What is the expected output? What do you see instead?
I would expect that pyodbc gets imported. But instead an import error occurs - 
saying that the module could not be found.

What version of the product are you using? On what operating system?
Windows 7, Apache 2.2.16, Python 2.7, mod_wsgi 3.3, pyodbc 2.1.8.
Also happens with different configurations on other windows machines (different 
os, apache and python).

Please provide any additional information below.
Maybe it has something to do with pyodbc binaries on windows because other non 
binary modules get imported correctly. This is a fresh system and afaicr i did 
nothing beside the obvious installation steps. The wsgi-sample and other 
wsgi-stuff works fine.

Original issue reported on code.google.com by Florian....@gmail.com on 11 Oct 2010 at 3:45

GoogleCodeExporter commented 8 years ago
I actually use pyodbc on Windows 7 myself, and I'm quite sure it isn't the 
binaries per se.  You'll need to log out the python path within the web 
application, which is probably better discussed on the news group: 
http://groups.google.com/group/pyodbc/topics

I can try to help, but I'm pretty sure this is an Apache configuration issue.

Original comment by mkleehammer on 20 Nov 2010 at 7:10

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 21 Nov 2010 at 5:20

GoogleCodeExporter commented 8 years ago
maybe it's related to this:
  http://stackoverflow.com/questions/3706293/why-do-no-python-dlls-built-with-msvc-load-with-mod-wsgi

Original comment by moo...@wwwendt.de on 21 Feb 2011 at 12:19

GoogleCodeExporter commented 8 years ago
I got the same problem when I using apache+wsgi+pyodbc2.1.8, but the 
pyodbc2.1.7 works for me.
Then I compareed the two version, I found the section in 2.1.7
     <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
is become to 
   <dependency>   
  </dependency>
I think that would be the issue.

Original comment by zpis...@gmail.com on 27 Mar 2011 at 9:15

GoogleCodeExporter commented 8 years ago
I don't see how this could be an Apache configuration issue. I'm using the 
standard configuration + wsgi (about 3 lines added to httpd.conf).

I tried pyodbc 2.1.7 with no luck. I also tried prebuilt binaries for other 
software that was built using MinGW and these get imported fine.
I checked the pyodbc binaries using Dependency Walker and it said that 
MSVCR90.DLL was missing. So i tried pyodbc 2.1.7 again using version 
9.0.21022.8 of MSVCR90.DLL. On import i get an import error message directly 
from apache:

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!

Program: C:\Progr...

R6034

An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
---------------------------

I really don't get it - i mean - it's the correct DLL, right?

Original comment by Florian....@gmail.com on 29 Mar 2011 at 9:36

GoogleCodeExporter commented 8 years ago
I'm stuck at the same point.  Slightly different configuration:
Win XP Pro; Python 2.6.5; Apache 2.2.16; PyODBC 2.1.8; WSGI 3.3 
("mod_wsgi-win32-ap22py26-3.3.so")

This post seems to be relevant:
http://groups.google.com/group/modwsgi/browse_thread/thread/13b4a5faa962d77/dd4d
6a03afbe16b6

... but I'm stuck, as I really have very little experience in building anything 
in C under Windows.  According to that post: I have to install Mingw32, and 
rebuild... what?  PyODBC?  mod_wsgi?

Can the Windows version of [PyODBC | mod_wsgi] just be built that way all the 
time?

-- Dan

Original comment by dhara...@gmail.com on 25 Apr 2011 at 7:38

GoogleCodeExporter commented 8 years ago
I always build pyodbc with MinGW.
It looks impossible to make pyodbc find MSVCR90.DLL. It's terrible.
Does anybody know what should I do to run pyodbc normally under Apache in 
Windows?
From Python shell it works fine.

Also I have the same problem with many releases of lxml.etree. Only lxml-2.2.2 
works without building with MinGW.
I think the reason for this is incorrect dependency information.

Alexander.

Original comment by rocker.y...@gmail.com on 26 Apr 2011 at 4:35

GoogleCodeExporter commented 8 years ago
http://groups.google.com/group/isapi_wsgi-dev/browse_thread/thread/03fa2b485ec22
81d

I believe this issue may be related to the msvc9compiler.py issues mentioned in 
the above link.   If so, this is really an issue in Python itself, but a 
workaround may be found by tweaking msvc9compiler.py to remove the Visual C 
runtime info from the DLL's manifest.  This let me get pyODBC working under IIS 
/ isapi. 

I've attached my modified copy of msvc9compiler.py in case it helps.

Original comment by pland...@gmail.com on 17 May 2011 at 11:08

Attachments:

GoogleCodeExporter commented 8 years ago
Using Python 2.7, mod_wsgi 3.3, Apache 2.2, pyodbc 2.1.8
Comment #8 seems to have helped me.
What didn't help:
* pyodbc 2.1.7
* Python 2.6
* older mod_wsgi, build from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
* building with mingw32

Attached build is what worked for me.

Original comment by dom...@gmail.com on 14 Jul 2011 at 1:35

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I know this is late, but I've been wrestling with this for months.

The specific problem is with mod_wsgi and apache, not pyodbc or python.  The 
quickest way to fix this issue is to download Apache built with vc9 C++ 
binaries.  You can find it here:
http://www.apachelounge.com/download/

However, I was using xampp which just recently (about two weeks from the time 
of writing this) has released their new package (1.7.7) which contains Apache 
2.2 built with the new vc9 C++ binaries.  You can find it here (all of the 
windows binaries are built with vc9):
http://www.apachefriends.org/en/xampp-windows.html

Both options above will get you back up and working.  Once I installed, I 
placed my modules in the modules dir and modified the httpd.conf and I was able 
to import and use pyodbc.

Thanks,

Daniel Kleehammer

Original comment by dkleeham...@gmail.com on 4 Oct 2011 at 2:00

GoogleCodeExporter commented 8 years ago
Please see issue 214.

Original comment by alfr...@gmail.com on 6 Oct 2011 at 2:45