*.pyd 文件无法加载,但 DependancyWalker 恢复正常,并且 ProcMon 显示它已加载
我正在尝试使用 Python 加载 *.pyd,但收到众所周知的“导入错误:DLL 加载失败:找不到指定的过程”。错误。
我已经完成了以下操作:
1.) 使用 Dependency Walker 调查了 *.pyd。 GPSVC.DLL 和 IESHIMS.DLL 出现丢失,但延迟加载,IEFRAME.DLL 也出现丢失导出,但也是延迟加载。据我了解,这些没有被使用,并且无论如何都是延迟加载,所以它们不应该是问题。
2.) 在 python 命令窗口中对 foo.pyd 执行“import foo”,并用 ProcMon 进行监视。 ProcMon 在“foo.pyd”上显示事件“LoadImage”,结果成功。
这似乎意味着 *.pyd 文件已正确加载。
那么我错过了什么。我的 Windows 诊断告诉我一切都很好,但 python 告诉我无法加载该东西(通常是由于缺少 dll 或符号)。
有想法吗?
谢谢!
I am trying to load a *.pyd with Python, but I receive the well known "Import Error: DLL load failed: the specified procedure can not be found." error.
I have already done the following:
1.) Investigated the *.pyd with Dependency Walker. GPSVC.DLL and IESHIMS.DLL came up as missing, but delay loaded, IEFRAME.DLL aslo came up as missing an export, but was also delay-loaded. It's my understanding that these are not used, and are delay load anyway, so they should not be the problem.
2.) Did an "import foo" on foo.pyd in the python command window, with ProcMon watching. ProcMon shows event "LoadImage" on "foo.pyd" with result SUCCESS.
This seems to imply that the *.pyd file loaded correctly.
So what am I missing. My windows diagnostics are telling me all is well, but python is telling me the thing cannot be loaded (usually due to a missing dll or symbol).
Ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
.pyd 文件是否与您使用的 Python 版本相同?加载错误 Python 版本的 .pyd 文件可能会产生该错误消息。
Dependency Walker 可以显示它链接到哪个 pythonNN.dll。
Is the .pyd file for the same version of Python you're using? Loading a .pyd file for the wrong Python version can produce that error message.
Dependency Walker can show you which pythonNN.dll it links to.
好的,这就是答案:
Windows 诊断(取决于、procmon 等)显示 DLL(或 pyd)加载正常。
Python 显示它加载不正常。
我发现 Windows 工具引用了隐藏在我的 C:\Window\SysWOW64 文件夹中的不同 Python26.dll。
第二个 Python26.dll(在 SysWOW64 中找到)具有主 python26.dll(由 Windows python 安装程序安装,在 C:\Python26 中找到)中缺少的符号。
我的 *.pyd 文件显然需要这个符号“_PyByteArray_empty_string”。
因此,当通过 Windows 诊断加载时,发现了 SysWOW64 dll,并且 *.pyd 已正确加载。从python加载时,发现C:\Python26\中的dll,符号丢失,加载失败。
这就是问题出现的原因。现在的问题是:为什么有两个版本的 Python26.dll 存在,一种带有 _PyByteArray_empty_string,一种没有?
我正在使用Python 2.6.6。也许这个符号在 2.6.6 中被删除,但在某些较旧的 2.6.x 版本中存在?
Ok here is the answer:
The windows diagnostics (depends, procmon, etc) were showing the DLL (or pyd) loading fine.
Python was showing that it was not loading fine.
I found that the windows tools were referring to a different Python26.dll hiding in my C:\Window\SysWOW64 folder.
This second Python26.dll (found in SysWOW64) has a symbol that is missing in the primary python26.dll (installed by the windows python installer, found in C:\Python26).
This symbol "_PyByteArray_empty_string", was apparently needed by my *.pyd file.
So when loading via windows diagnostics, the SysWOW64 dll was found, and the *.pyd loaded properly. When loading from python, the dll in C:\Python26\ was found, the symbol was missing, and load failed.
So that is WHY the problem manifested. The question now is: Why are there two versions of Python26.dll floating around, one with _PyByteArray_empty_string, and one without?
I'm using Python 2.6.6. Perhaps this symbol is removed in 2.6.6 but present in some older 2.6.x release?
如果您有一个文件
foo.pyd
,为了使import foo
成功,必须有一个名为initfoo
的外部可访问函数。如果存在,Dependency Walker 将显示此功能(通常是唯一的功能)。 Python 需要调用initfoo
来初始化foo
模块。注意:如果这是问题所在,我希望得到更明确的错误消息:
您说您正在“尝试加载 *.pyd 文件”。这只是一种奇怪的描述 import foo 的方式还是别的什么?
你创建了pyd吗?如果不是,那是谁干的?你问过他们吗?这个 pyd 是否可以在网络上使用,以便其他人可以尝试加载/导入它?
If you have a file
foo.pyd
, forimport foo
to succeed, there must be an externally accessible function namedinitfoo
. Dependency Walker will show this (typically the ONLY function) if it exists.initfoo
needs to be called by Python to initialise thefoo
module.Note: I would expect a more explicit error message if this were the problem:
You say that you are "trying to load a *.pyd file". Is that just a strange way of describing
import foo
or is it something else?Did you create the pyd? If not, who did? Have you asked them? Is this pyd available on the web so that others could try to load/import it?