*.pyd 文件无法加载,但 DependancyWalker 恢复正常,并且 ProcMon 显示它已加载

发布于 2024-11-01 00:58:45 字数 476 浏览 4 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我纯我任性 2024-11-08 00:58:45

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

微凉徒眸意 2024-11-08 00:58:45

好的,这就是答案:

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?

七秒鱼° 2024-11-08 00:58:45

如果您有一个文件 foo.pyd,为了使 import foo 成功,必须有一个名为 initfoo 的外部可访问函数。如果存在,Dependency Walker 将显示此功能(通常是唯一的功能)。 Python 需要调用 initfoo 来初始化 foo 模块。

注意:如果这是问题所在,我希望得到更明确的错误消息:

>>> import fubar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initfubar)
>>>

您说您正在“尝试加载 *.pyd 文件”。这只是一种奇怪的描述 import foo 的方式还是别的什么?

你创建了pyd吗?如果不是,那是谁干的?你问过他们吗?这个 pyd 是否可以在网络上使用,以便其他人可以尝试加载/导入它?

If you have a file foo.pyd, for import foo to succeed, there must be an externally accessible function named initfoo. Dependency Walker will show this (typically the ONLY function) if it exists. initfoo needs to be called by Python to initialise the foo module.

Note: I would expect a more explicit error message if this were the problem:

>>> import fubar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initfubar)
>>>

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文