语境
是否有命令可以增强收到的错误消息,以便 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.dll
至api-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/