Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
758 views
in Technique[技术] by (71.8m points)

python - DLL load failed while importing cv2

I got stuck with this error while building OpenCV from source with GStreamer features. Here is the error:

Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:Program FilesPython38libsite-packagescv2\__init__.py", line 102, in <module>
 bootstrap()
File "C:Program FilesPython38libsite-packagescv2\__init__.py", line 90, in bootstrap
 import cv2
ImportError: DLL load failed while importing cv2: Belirtilen modül bulunamad?.
>>>

My setup is:
Gstreamer 1.18.2 (I tried both MinGW 64-bit and MSVC 64-bit same results)
Python 3.8
OpenCV 4.5.1

What I have done so far:

  1. I change init.py file which is loading module to DEBUG mode and here is what I found:
>>> import cv2
OpenCV loader: os.name="nt"  platform.system()="Windows"
OpenCV loader: loading config: C:Program FilesPython38libsite-packagescv2config.py
OpenCV loader: loading config: C:Program FilesPython38libsite-packagescv2config-3.8.py
OpenCV loader: PYTHON_EXTENSIONS_PATHS=['C:/Program Files/Python38/Lib/site-packages/cv2\python-3.8']
OpenCV loader: BINARIES_PATHS=['D:/build6/install\x64/vc16/bin']
OpenCV loader: PATH=D:/build6/installx64/vc16/bin;C:Program FilesPython38Scripts;C:Program FilesPython38;C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.1in;C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.1libnvvp;C:Program Files (x86)Common FilesOracleJavajavapath;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;C:Program FilesGitcmd;C:Program FilesPuTTY;C:Program FilesNVIDIA CorporationNsight Compute 2020.2.0;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;C:Program FilesCMakein;C:gstreamer1.0mingw_x86_64in;C:gstreamer1.0mingw_x86_64lib;C:gstreamer1.0mingw_x86_64libgstreamer-1.0;D:uild6installx64vc16staticlib;D:uild6installx64vc16in;C:UserssearoAppDataLocalMicrosoftWindowsApps;C:UserssearoAppDataLocalProgramsMicrosoft VS Codein;C:gstreamer1.0mingw_x86_64in;C:gstreamer1.0mingw_x86_64lib;C:gstreamer1.0mingw_x86_64libgstreamer-1.0;D:uild6installx64vc16in;D:uild6installx64vc16staticlib;C:Windowssystem32;
OpenCV loader: replacing cv2 module
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:Program FilesPython38libsite-packagescv2\__init__.py", line 102, in <module>
    bootstrap()
  File "C:Program FilesPython38libsite-packagescv2\__init__.py", line 90, in bootstrap
    import cv2
ImportError: DLL load failed while importing cv2: Belirtilen modül bulunamad?.
  1. I am thinking it is path issue because I opened the cv2.cp38-win_amd64.pyd file with Dependency Walker to find which DLLs missing and I found that many DLLs which looks like missing are in the System32 folder. Missing DLLs
  2. Since that I am thinking it is a path issue my paths are looking fine. And when I build OpenCV without GStreamer features it is working totally correct. Even when I build OpenCV with extra contrib modules and CUDA. My variables for both user and system:

System PATHs
System and Enviroment Variables
User PATHs

I couldn't solve this for weeks. I found another solution today but I really want OpenCV to work with GStreamer. I would be glad if someone can solve.

question from:https://stackoverflow.com/questions/65646874/dll-load-failed-while-importing-cv2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...