Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3.7.0+opencv_python3.4.2.17, "from .cv2 import *" says "DLL load failed:" #116

Closed
tianxiawuzhe opened this issue Aug 9, 2018 · 10 comments

Comments

@tianxiawuzhe
Copy link

I install python3.7 and opencv-python 3.4.2.17 (using pip install), all are ok.
when "import cv2", it says:
Traceback (most recent call last):
File "", line 1, in
File "XXXX\lib\site-packages\cv2_init_.py", line 3, in
from .cv2 import *
ImportError: DLL load failed: could not find this module.
I read some solutions, but not resolved.
I install python3.6.3 and opencv-python 3.4.0.12 on the same windows 7. it runs ok.
That means, the os env could be ok.
any suguesstions?

@tianxiawuzhe
Copy link
Author

Thanks. Resolved!
by #114, I download depends from http://www.dependencywalker.com/.
Shows:
API-MS-WIN-DOWNLEVEL-SHLWAPI-L1-1-0.DLL
PYTHON37.DLL
IESHIMS.DLL
Error open File.
Then, I compare the dependency of cv2.cp36-win32.pyd and cv2.cp37-win32.pyd.
may be API-MS-WIN-DOWNLEVEL-SHLWAPI-L1-1-0.DLL is missing on windows 7.
Download api-ms-win-downlevel-shlwapi-l1-1-0.dll from 'https://www.dll-files.com/api-ms-win-downlevel-shlwapi-l1-1-0.dll.html', choose x86 version.
copy it to C:\Windows\System32 and C:\Windows\SysWOW64.
And 'import cv2' is ok.
Thanks very much!

@wb666greene
Copy link

wb666greene commented Aug 10, 2018

@tianxiawuzhe

Which version of the dll did you download? There are 5 on the site!

Were you using 32 or 64 bit Python 3.7?

I'm trying to port some Linux python code to windows 7, all the other pip installs seem fine, but I'm dead before I start without import cv2 working.

I've been given a 64-bit Windows 7 Professional machine to work with, so I've startedwith the 64-bit Python3.7

@wb666greene
Copy link

Followup.

I needed the 64-bit version 6.3.9600.16384:
https://www.dll-files.com/download/9cada7cc00753250c1beda32c23e22ee/api-ms-win-downlevel-shlwapi-l1-1-0.dll.html?c=NUlOeGlpQkZoankwNVNGVmUveUZ2UT09

Added it to both system32 and syswow64

I'm using 64-bit python 3.7.0 on windows 7 professional. I was getting depressed as it was the 4th one I tried :(

At least now I've reached first base.

@tianxiawuzhe
Copy link
Author

@tianxiawuzhe

Which version of the dll did you download? There are 5 on the site!

Were you using 32 or 64 bit Python 3.7?

I'm trying to port some Linux python code to windows 7, all the other pip installs seem fine, but I'm dead before I start without import cv2 working.

I've been given a 64-bit Windows 7 Professional machine to work with, so I've startedwith the 64-bit Python3.7

Sorry for late.
windows7 professional-64bit, python3.7-32bit ( installed by anaconda)
dll is the first one on 'https://www.dll-files.com/api-ms-win-downlevel-shlwapi-l1-1-0.dll.html' (17.3kb)
maybe you should download x64 dll for python3.7.

@wb666greene
Copy link

wb666greene commented Sep 13, 2018 via email

@Vhati
Copy link

Vhati commented Oct 6, 2018

Encountered this and fixed it by downloading the missing dll, mentioned above.
"api-ms-win-downlevel-shlwapi-l1-1-0.dll" v10.0.14393.0 32bit (17.3 kb)

Win7 Pro 64bit, Python 3.6.5 32bit (without Anaconda), opencv-python 3.4.3.18.

Already had the dependencies recommended on PyPI: "Visual C++ redistributable 2015" and "Universal C Runtime" update.

#!/usr/bin/env python3
import os

# Include a bundled dll in the search path.
script_dir = os.path.realpath( os.path.dirname( __file__ ) )
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + script_dir
import cv2

# Do stuff with OpenCV...

@azhaoaigaga
Copy link

@wb666greene Did it work out? I used Windows server 2008, and the above problems also appeared, but I did not lose the api-ms-win-downlevel-shlwapi-l1-1-0 in system32 and syswow64. Do I still need to download and replace the DLL, or do I have other solutions? This has been bothering me for several days.

@wb666greene
Copy link

@azhaoaigaga As far as I can tell it did. I'm not much of a Windows user anymore, I was helping a friend setup a system. This was a 64-bit system, you may need differnet for 32-bit.
I ultimately needed to install:
api-ms-win-downlevel-shlwapi-l1-1-0.dll
Windows6.1-KB2999226-x64.msu
vc_redist.x64.exe
vc_redist.x86.exe

To get everything to work.
Hope this helps, but I haven't touched a Windows system since I initially posted and eventually got his Python3 system working.

@skvark
Copy link
Member

skvark commented Aug 14, 2019

Windows server is probably missing some dependencies since it's headless by default. Never download DLL files from the internet, they are most likely malware / viruses. You could try to install the opencv-python-headless version which is targeted for headless server environments. Just remember to uninstall opencv-python first.

If that does not work, the issue is probably related to other missing DLL files which are not present on Windows Server versions. See for example https://withinrafael.com/2017/09/09/windows-container-app-compat-opencv-python/. In that case it might be that you have to build OpenCV manually and disable some Cmake flags to turn off features which are not supported by Windows Server 2008.

@azhaoaigaga
Copy link

@wb666greene @skvark thanks,i‘ll try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants