我正在调试由使用lxml的脚本导入的另一个dll。我需要从lxml项目创建一个objectify_d.pyd和etree_d.pyd。我按照这里的构建说明成功构建了这些:http://lxml.de/build.html但使用此命令:
python setup.py build --debug --static
我试过这样做:
python setup.py build --debug
但这没效果。
构建似乎成功了。创建了objectify_d.pyd和etree_d.pyd。使用这些文件(通过将它们复制到c:/ python27 / lib / site-packages / lxml /)并运行调试python构建,我在尝试导入时会得到以下内容:
>>> from lxml import objectify
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
[83669 refs]
然后我在调试器中运行python,看到对LoadLibraryEx的调用失败(返回NULL)。 GetLastError()调用返回126,这意味着它找不到dll。路径是正确的。所以我希望它找不到依赖的DLL。我在构建它的机器上运行它,因此它不是缺少的运行时库。
这是我构建dll时打印的内容:
</c/lxml/lxml-2.3 Trunk>
$python setup.py build --debug --static
Building lxml version 2.3.
Building with Cython 0.15.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
Building against libxml2/libxslt in one of the following directories:
..\iconv-1.9.2.win32\lib
..\libxml2-2.7.8.win32\lib
..\libxmlsec-1.2.18.win32\lib
..\libxslt-1.1.26.win32\lib
..\zlib-1.2.5\lib
c:\python27
running build
running build_py
running build_ext
skipping 'src/lxml\lxml.etree.c' Cython extension (up-to-date)
building 'lxml.etree' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Od /MDd /W3 /GS- /Z7 /D_DEBUG -I..\iconv-1.9.2.win32\include -I..\libxml2-2.7.8.win 32\include -I..\libxmlsec-1.2.18.win32\include -I..\libxslt-1.1.26.win32\include -I..\zlib-1.2.5\include -I..\ -IC:\python27\include -IC:\python27\PC /TcC:\lxml \lxml-2.3\src\lxml\lxml.etree.c /Fobuild\temp.win32-2.7\Debug\src/lxml\lxml.etree.obj -w DEBUG
cl : Command line warning D9025 : overriding '/W3' with '/w'
cl : Command line warning D9024 : unrecognized source file type 'DEBUG', object file assumed
cl : Command line warning D9027 : source file 'DEBUG' ignored
lxml.etree.c
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:no /DEBUG /pdb:None /LIBPATH:..\iconv-1.9.2.win32\lib /LIBPATH:..\l ibxml2-2.7.8.win32\lib /LIBPATH:..\libxmlsec-1.2.18.win32\lib /LIBPATH:..\libxslt-1.1.26.win32\lib /LIBPATH:..\zlib-1.2.5\lib /LIBPATH:c:\python27 /LIBPATH:C:\p ython27\libs /LIBPATH:C:\python27\PCbuild libxslt_a.lib libexslt_a.lib libxml2_a.lib iconv_a.lib zlib.lib WS2_32.lib /EXPORT:initetree build\temp.win32-2.7\Debu g\src/lxml\lxml.etree.obj /OUT:build\lib.win32-2.7\lxml\etree_d.pyd /IMPLIB:build\temp.win32-2.7\Debug\src/lxml\etree_d.lib /MANIFESTFILE:build\temp.win32-2.7\Debug\src/lxml\etree_d.pyd.manifest
Creating library build\temp.win32-2.7\Debug\src/lxml\etree_d.lib and object build\temp.win32-2.7\Debug\src/lxml\etree_d.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
lxml.etree.obj : warning LNK4049: locally defined symbol _xmlFree imported
lxml.etree.obj : warning LNK4049: locally defined symbol _xmlMalloc imported
lxml.etree.obj : warning LNK4049: locally defined symbol _xsltDocDefaultLoader imported
lxml.etree.obj : warning LNK4049: locally defined symbol _xsltLibxsltVersion imported
zlib.lib(adler32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(crc32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(deflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzclose.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzlib.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzread.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzwrite.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(inffast.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(inflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(inftrees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(trees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(zutil.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest build\temp.win32-2.7\Debug\src/lxml\etree_d.pyd.manifest -outputresource:build\lib.win32-2.7\lxml\etree_d.pyd;2 skipping 'src/lxml\lxml.objectify.c' Cython extension (up-to-date)
building 'lxml.objectify' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Od /MDd /W3 /GS- /Z7 /D_DEBUG -I..\iconv-1.9.2.win32\include -I..\libxml2-2.7.8.win32\include -I..\libxmlsec-1.2.18.win32\include -I..\libxslt-1.1.26.win32\include -I..\zlib-1.2.5\include -I..\ -IC:\python27\include -IC:\python27\PC /TcC:\lxml\lxml-2.3\src\lxml\lxml.objectify.c /Fobuild\temp.win32-2.7\Debug\src/lxml\lxml.objectify.obj -w DEBUG
cl : Command line warning D9025 : overriding '/W3' with '/w'
cl : Command line warning D9024 : unrecognized source file type 'DEBUG', object file assumed
cl : Command line warning D9027 : source file 'DEBUG' ignored
lxml.objectify.c
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:no /DEBUG /pdb:None /LIBPATH:..\iconv-1.9.2.win32\lib /LIBPATH:..\libxml2-2.7.8.win32\lib /LIBPATH:..\libxmlsec-1.2.18.win32\lib /LIBPATH:..\libxslt-1.1.26.win32\lib /LIBPATH:..\zlib-1.2.5\lib /LIBPATH:c:\python27 /LIBPATH:C:\python27\libs /LIBPATH:C:\python27\PCbuild libxslt_a.lib libexslt_a.lib libxml2_a.lib iconv_a.lib zlib.lib WS2_32.lib /EXPORT:initobjectify build\temp.win32-2.7\Debug\src/lxml\lxml.objectify.obj /OUT:build\lib.win32-2.7\lxml\objectify_d.pyd /IMPLIB:build\temp.win32-2.7\Debug\src/lxml\objectify_d.lib /MANIFESTFILE:build\temp.win32-2.7\Debug\src/lxml\objectify_d.pyd.manifest
Creating library build\temp.win32-2.7\Debug\src/lxml\objectify_d.lib and object build\temp.win32-2.7\Debug\src/lxml\objectify_d.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
zlib.lib(adler32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(crc32.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(deflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzclose.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzlib.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzread.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(gzwrite.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(inffast.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(inflate.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(inftrees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(trees.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
zlib.lib(zutil.obj) : warning LNK4099: PDB 'zlib.pdb' was not found with '..\zlib-1.2.5\lib\zlib.lib' or at 'C:\lxml\lxml-2.3\zlib.pdb'; linking object as if no debug info
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest build\temp.win32-2.7\Debug\src/lxml\objectify_d.pyd.manifest -outputresource:build\lib.win32-2.7\lxml\objectify_d.pyd;2
其他一些信息:
如果有人可以为我提供适用于Windows的lxml调试版本,或者请指出如何使用与调试dll混合的版本python dll,我会满意。
答案 0 :(得分:1)
您是在Cygwin环境中构建,然后尝试在Windows中运行?尝试在Windows中构建。
答案 1 :(得分:1)
我没有尝试构建lxml的调试版本,但它几乎肯定无法工作。根据我的记忆,lxml附带的设置脚本仅用于构建发行版本。
您可以利用此功能,只需为发布版本生成调试符号(.pdb)。这个程序相当复杂,但这里有一个概述:
就是这样! :)我想链接到detailed procedure可能更合理。
免责声明:我是帖子的作者。