当我使用apache2 + modwsgi启动我的应用程序时 我抓了
Exception Type: ImportError Exception Value: DLL load failed: The specified module could not be found.
在行
from lxml import etree
使用Django dev服务器一切正常 已安装Visual C ++ Redistributable 2008
Dependency walker告诉msvcrt90.dll错过了 但是cx_Oracle也有相同的情况,但是cx_Oracle的dll加载正确
任何想法?
Windows 2003服务器64位和Windows XP sp3 32位 python 2.7 32位 cx_Oracle 5.0.4 32位UPD : 下载libxml2-2.7.7和libxslt-1.1.26
尝试使用setup.py build --compiler mingw32
进行构建Building lxml version 2.3. Building with Cython 0.14.1. ERROR: 'xslt-config' is not recognized as an internal or external command, operable program or batch file. ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt running build running build_py running build_ext skipping 'src/lxml\lxml.etree.c' Cython extension (up-to-date) building 'lxml.etree' extension C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c src/lxml\lxml.etree.c -o build\temp.win32-2.7\Release\src\lxml\lxml.et ree.o -w writing build\temp.win32-2.7\Release\src\lxml\etree.def C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\src\lxml\lxml.etree.o build\temp.win32-2.7\Release\src\lxml\etree.def -LC:\Python27\lib s -LC:\Python27\PCbuild -llibxslt -llibexslt -llibxml2 -liconv -lzlib -lWS2_32 -lpython27 -lmsvcr90 -o build\lib.win32-2.7\lxml\etree.pyd build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0xd11): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0xd24): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x1ee92): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x1eed6): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x2159e): undefined reference to `_imp__xmlMalloc' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x2e741): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x2e784): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x3f157): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x3f19a): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x3f4ac): undefined reference to `_imp__xmlFree' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0x3f4ef): more undefined references to `_imp__xmlFree' follow build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0xb1ad5): undefined reference to `xsltLibxsltVersion' build\temp.win32-2.7\Release\src\lxml\lxml.etree.o:lxml.etree.c:(.text+0xb1b9a): undefined reference to `xsltDocDefaultLoader' collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1
UPD2 : 我理解为什么导入cx_Oracle工作正常:cx_Oracle.pyd包含“MSVCRT.dll”依赖etree.pyd没有它
答案 0 :(得分:2)
确实是因为'msvcrt90.dll'。从Python 2.6的微补丁版本的某个地方开始,他们停止构建自动依赖DLL的扩展模块,并依靠Python可执行文件来实现它。当嵌入到其他系统中时,您依赖于链接到DLL的可执行文件,而在Apache的情况下则不依赖于。因此,Python的变化打破了许多在Windows上嵌入Python的系统,唯一的解决方案是每个扩展模块都有自己的依赖所需的DLL,许多人没有。 psycopg2扩展受到严重影响,他们已经更改了他们的构建,现在又将依赖项添加回来。您可能会在psycopg2中搜索问题。其中一个解决方案是在Windows上使用MinGW编译器重建扩展。