python - 如何在python中找到 "ImportError: DLL load failed while importing"中哪个DLL失败?

标签 python debugging dll anaconda

语境
是否有命令可以增强收到的错误消息,以便 python 显示 .dll找不到文件?
对于错误:

python test_cv2.py
Traceback (most recent call last):
  File "test_cv2.py", line 1, in <module>
    import cv2
  File "E:\Anaconda3\envs\py38\lib\site-packages\cv2\__init__.py", line 5, in <module>
    from .cv2 import *
ImportError: DLL load failed while importing cv2: The specified module could not be found.

(py38) E:\somepath>
我想确定哪个 .dll文件实际上没有被找到。为此,我下载并运行 DependenciesGui.exe来自 this repository. .接下来我喂了DependenciesGui.exe cv2.cp38-win_amd64.pyd表示api-ms-win-core-wow64-l1-1-1.dll失踪,除其他外。
我目前没有办法验证 .dll dependenciesGUI.exe 报告丢失的文件也是 python 3.8 在 anaconda 环境中找不到的文件。
一种隐式验证 python 3.8 是否丢失 .dll 的方法文件与 dependenciesGUI.exe 报告丢失的相同文件相同将下载并粘贴所有丢失的.dll文件到 ../system32/ .然后检查错误消息是否消失/更改。然而,.dll 之一报告丢失的文件是:api-ms-win-core-wow64-l1-1-1.dll我还没有找到(在线)。我还试图欺骗复制和重命名api-ms-win-core-wow64-l1-1-0.dllapi-ms-win-core-wow64-l1-1-1.dll但是(幸运的是)没有启用 dpendenciesGUI.exe认识.dll找到的文件。
问题
如何使 python 的错误消息/回溯明确提及 .dll文件(第一个 .dll 文件)没有找到?
笔记
这不是解决 xy-problem安装 opencv .

最佳答案

简短的回答:没有。
虽然这可能并非完全不可能,但需要绑定(bind)一个像 dependenciesGUI 这样的工具。在 Python 中,为了能够在给定的上下文中调用它(即考虑到 Python 中 dll 的实际搜索路径和已加载的动态库)。这将是相当多的工作,但收效甚微。实际上,Windows 上 Python>=3.8 中的默认搜索路径应该与 dependenciesGUI 中的一个非常相似。 ,所以丢失的dll应该是一样的。就个人而言,我正在为 Python 开发预编译的二进制发行版,到目前为止 dependenciesGUI足以识别 Python 导入时缺少的库。

关于python - 如何在python中找到 "ImportError: DLL load failed while importing"中哪个DLL失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62732358/

相关文章:

python - 如何使用python启动两个线程?

c# - 如何附加调试器以从托管(C#)包装器进入 native (C++)代码?

debugging - Haskell GHCI,似乎无法进入主模块的交互式执行

visual-c++ - 在 mingw 中使用 msvc lib

python - win32api.dll 将无法安装

javascript - 转置列数据并将其复制到每行

python - OpenCV - 读取 16 位灰度图像

javascript - 带有 JavaScript 的 Python

debugging - 为什么调试时寄存器值没有改变?

c# - 在 C# 中未处理 TypeLoadException