Giter Site home page Giter Site logo

Comments (29)

ranjiewwen avatar ranjiewwen commented on July 18, 2024 8

i meet the same problem, and i solve it from stackoverflow: https://stackoverflow.com/questions/43184887/dll-load-failed-error-when-importing-cv2

If you are using Anaconda, this is a problem in Anaconda release. (Refer this issue)

You can fix this issue by copying python3.dll file to Anaconda3 folder (where python.exe is located)

How to get "python3.dll"

In cmd, type python --version to find whether your installation is 64-bit or 32-bit
download python 3.x embeddable zip file from here
Extract the zip file and copy python3.dll file to Anaconda3 folder

from opencv-python.

kenliang18 avatar kenliang18 commented on July 18, 2024 6

I install a totally new windows 7 system,and I encountered the same problem as well.Then I find the dll below in other machine ,put it into C:\Windows\System32, and I solve the import cv2 problem.
my test machine info:windows 7 ultimate;Anaconda 5.0.1.
api-ms-win-downlevel-shlwapi-l1-1-0.dll

from opencv-python.

gabeorlanski avatar gabeorlanski commented on July 18, 2024 3

Yea kinda got out of hand. Sorry for that. Do hope this dialogue would be helpful to at least 1 other person.

from opencv-python.

caide199212 avatar caide199212 commented on July 18, 2024 2

Thank you very much.

Yes, it's on Windows. And the method in this website solved my problem. https://www.scivision.co/install-opencv-python-windows/

Previously, I installed opencv using conda install opencv, while now I use conda install -c conda-forge opencv.

from opencv-python.

saihas avatar saihas commented on July 18, 2024 2

use conda update -all to get a stable environment. Then everything will be alright.

from opencv-python.

skvark avatar skvark commented on July 18, 2024

Thanks, that's a really good and detailed report. I'll add a mention about the dependency to the README.

What comes to Anaconda support in general, these packages are targeted only for the original CPython. They may work with other distributions, but it's better to use for example Anaconda's package management system to install packages for that distribution.

Personally I like to use official Python versions because many of the scientific packages can be nowadays found (except SciPy's Windows builds) as precompiled wheels from PyPI. This was not true few years back but the situation is getting better. It would be nice if we had all packages available in PyPI but I guess it's not yet possible. Some of the packaging work is done currently twice (like the menpo/opencv3 package) so the situation is a bit suboptimal as the people who are willing to do this work are somewhat rare in the open source world.

from opencv-python.

gabeorlanski avatar gabeorlanski commented on July 18, 2024

I am having this same issue. I just updated the visual studio but that didn't fix it :(

from opencv-python.

skvark avatar skvark commented on July 18, 2024

Well, as @talmo wrote above, the issue is in Anaconda. The linkage rules in PEP 384 clearly state that under Windows applications are linked with python3.dll. You just have to download the correct python3.dll and place it manually to path until Anaconda provides a fix for this.

from opencv-python.

gabeorlanski avatar gabeorlanski commented on July 18, 2024

do you mean the anaconda path or the open cv path? @skvark

from opencv-python.

skvark avatar skvark commented on July 18, 2024

I think any place that is in the PATH environment variable should be enough. For example C:\Anaconda3 if that's where your installation is located.

from opencv-python.

gabeorlanski avatar gabeorlanski commented on July 18, 2024

@skvark now I get ImportError: DLL load failed: %1 is not a valid Win32 application. When Trying to import after putting the dll with anaconda

from opencv-python.

skvark avatar skvark commented on July 18, 2024

As the error says, you have probably downloaded a 64-bit version while your installation is 32-bit.

from opencv-python.

gabeorlanski avatar gabeorlanski commented on July 18, 2024

I have the 64 windows. Do you mean my python installation?

from opencv-python.

skvark avatar skvark commented on July 18, 2024

Yes, I mean Python installation. Please ask this kind of questions in the future for example in Stackoverflow or in some other QA forum.

from opencv-python.

gboeer avatar gboeer commented on July 18, 2024

Thanks, this helped a lot!

from opencv-python.

roch02 avatar roch02 commented on July 18, 2024

Thanks, finally got it working!

from opencv-python.

swetshaw avatar swetshaw commented on July 18, 2024

Thank you . Awesome explanation. I was able to resolve it. @talmo

from opencv-python.

chenliqiong avatar chenliqiong commented on July 18, 2024

Perfect! Successfully solved my problem.

from opencv-python.

skvark avatar skvark commented on July 18, 2024

The latest Anaconda releases include python3.dll so I'm closing this issue now. However, I will keep reference to this issue in README.

from opencv-python.

xzl524 avatar xzl524 commented on July 18, 2024

Thank you! It solves my case.

from opencv-python.

tortelee avatar tortelee commented on July 18, 2024

thanks,it really helps me!!

from opencv-python.

caide199212 avatar caide199212 commented on July 18, 2024

For my case, there is already python3.dll in Anaconda3 file. Still, there is the importerror for cv2.

The version of Anaconda is 64 bits, the installed python in Anaconda is 32 bits, I wonder if this kind of version mismatch cause the import error?

BTW, other packages such keras and numpy work well.

from opencv-python.

skvark avatar skvark commented on July 18, 2024

I have no idea about Anaconda or how it works internally. I presume you are using Windows? Check the FAQ in readme: https://github.com/skvark/opencv-python#frequently-asked-questions

How did you install opencv-python? Have you removed other conflicting OpenCV installations?

Also, what's the exact error? If the error is the same as in this issue, then check the .pyd file with http://www.dependencywalker.com/ to see which dependency is missing.

from opencv-python.

skvark avatar skvark commented on July 18, 2024

Then your issue had nothing to do with opencv-python or this repository. Please report conda issues to conda repositories in the future.

from opencv-python.

speedzshaw avatar speedzshaw commented on July 18, 2024

I'm using win7.
When I open cmd under Anaconda3\Lib\site-packages (where opencv is installed), I'm able to import cv2.
Other than this directory, it reports specified module could not be found.
I add the directory to the system PATH variable. But still don't work.
What do you think might be the cause?

from opencv-python.

skvark avatar skvark commented on July 18, 2024

Sounds like you're not using opencv-python (pip install opencv-python) package. This is issue tracker, not a QA forum. Please ask your question at Stack Overflow.

from opencv-python.

menzec avatar menzec commented on July 18, 2024

It works well on windows 7.Thanks! @kenliang18
download api-ms-win-downlevel-shlwapi-l1-1-0.dll file and put it in 'C:\Windows\Sysytem32'
then run command regsvr32 api-ms-win-downlevel-shlwapi-l1-1-0.dll /s in cmd

from opencv-python.

ZXsilence avatar ZXsilence commented on July 18, 2024

@kenliang18 thanks! it worked for me too, and i just push it into C:\Windows\System32 without running command regsvr32 api-ms-win-downlevel-shlwapi-l1-1-0.dll

from opencv-python.

rxy007 avatar rxy007 commented on July 18, 2024

#116

from opencv-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.