ImportError: DLL load failed while importing cv2: 未找到指定的模块

huangapple go评论64阅读模式
英文:

anaconda ImportError: DLL load failed while importing cv2: The specified module could not be found

问题

我正在尝试在我的笔记本电脑上安装OpenCV,但一直出现ImportError: DLL load failed while importing cv2: The specified module could not be found.的错误。我尝试在Anaconda环境中使用conda install -c conda-forge opencv进行安装,但结果也是一样的,如果我使用普通的Python 3.10解释器,使用opencv-pythonopencv-contrib-python也会得到相同的结果。我还尝试自己编译模块,但cv2.cp310-win_amd64也会出现相同的错误...

是否有预构建的二进制文件可以使用?或者我应该寻找不同的机器学习模块?

昨天我回家后尝试在我的个人电脑上安装opencv-python,它立即起作用。我的个人电脑上有GTX 1070,而我工作笔记本上有RTX A1000,我需要在工作笔记本上安装OpenCV。所以我认为可能不支持CUDA核心。我找到了这个教程https://machinelearningprojects.net/build-opencv-with-cuda-and-cudnn/,但在安装Nvidia SDK、cudnn并从源代码编译OpenCV后,我仍然遇到相同的错误。即使将OpenCV的输出文件夹和CUDA SDK的bin文件夹附加到Python的dll_path中也没有解决问题。

像这里建议的禁用BUILD_SHARED_LIBS也没有效果...https://forum.opencv.org/t/opencv-w-cuda-build-seems-successful-but-import-cv2-fails/11328/3

英文:

I am trying to install opencv on my laptop but I keep getting ImportError: DLL load failed while importing cv2: The specified module could not be found.
I tried installing installing with conda install -c conda-forge opencv in an anaconda env.
But I also get the same result if I use my normal python 3.10 interpreter with opencv-python and opencv-contrib-python.
I also tried to compile the module myself but cv2.cp310-win_amd64 gives me the same error as well...

Isnt there just an prebuild binary I can use? or should I look for an different ML module?

Yesterday when I came home I tried installing opencv-python on my personal computer. And it worked instantly. I have an GTX 1070 in that pc and an RTX A1000 in the work laptop I need opencv on. So I tought that the cuda cores might not be supported or something.
I found this tutorial https://machinelearningprojects.net/build-opencv-with-cuda-and-cudnn/
But after installing the Nvidia SDK, cudnn and compiling opencv from source I still get the same error.
Even with appending the opencv output folder and the cuda sdk bin folder to python's dll_path.

Disabling BUILD_SHARED_LIBS as suggested in here also does nothing....
https://forum.opencv.org/t/opencv-w-cuda-build-seems-successful-but-import-cv2-fails/11328/3

答案1

得分: 1

这发生在我身上就在今早,我通过使用pip安装opencv来修复它。首先,我移除了conda的opencv安装。在安装了opencv的环境中执行以下命令:

conda remove opencv

一旦移除了,执行以下命令:

pip install opencv-python

希望对你有帮助。

英文:

This happened to me just this morning, and I fixed it by installing opencv using pip. First, I removed conda's opencv installation. In the environment where it is installed type

conda remove opencv

Once it is removed, type

pip install opencv-python

Hope it helps

答案2

得分: 0

使用Python 3.6与conda install -c conda-forge opencv=3.2.0,如此处所述:https://stackoverflow.com/questions/44668602/opencv-python-importerror-dll-load-failed-the-specified-module-could-not-be-fo?rq=1 已解决了我笔记本上的RTX A1000的问题。奇怪的是,opencv在我的桌面上与GTX 1070的Python 3.10一起工作。

英文:

Using python 3.6 with conda install -c conda-forge opencv=3.2.0 as described here https://stackoverflow.com/questions/44668602/opencv-python-importerror-dll-load-failed-the-specified-module-could-not-be-fo?rq=1 solved the issue on my laptop with an RTX A1000. Weird opencv works with python 3.10 on my desktop with an GTX 1070

huangapple
  • 本文由 发表于 2023年2月8日 22:25:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75387197.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定