Solve the problems of opencv installation in Python3 environment

First check whether the location of the whl file is wrong.

Secondly, upgrade numpy to the latest version, code: !pip install --upgrade numpy, I upgraded to 1.19.5. There is a dependency between opencv and numpy, and it must match it. (Some people say that it is because the numpy version is too high and needs to be downgraded. Code: pip install -U numpy==1.11.0 1.11.0 is the version number you want to downgrade to. But I use the latest version of numpy, personally tested pass)

1 First download the package, opencv download address: version release - open CV (opencv.org)

Note: The path of the whl file is the same as other package paths, for example, my other package path: D:\anaconda3\Lib\site-packages

What I downloaded is: opencv_python-4.4.0-cp36-cp36m-win_amd64.whl, this can refer to your own Python version, use the code import wheel.pep425tags as w
print(w.get_supported()) to check, select the corresponding name Yes, as shown in the picture below.

2 Next use pip to install

Installation code: !pip install D:\anaconda3\Lib\site-packages\opencv_python-4.4.0-cp36-cp36m-win_amd64.whl

 

After the installation is complete, import the package import cv2 and try it out. If no error is reported, it will succeed.

3 Problems encountered during installation

DLL load failed: The specified module could not be found

numpy.core.multiarray failed to import package and numpy dependency problem

The installation was successful, but at the beginning I placed the whl file in the wrong place, which caused an error in the subsequent import cv2. It will be fine after changing the path again

After changing the path and reinstalling, it shows that it has been installed, but it does not affect 

 

Solve the opencv installation problem:

First check whether the location of the whl file is wrong. Secondly, upgrade numpy to the latest version, code: !pip install --upgrade numpy, I upgraded to 1.19.5. There is a dependency between opencv and numpy, and it must match it. (Some people say that it is because the numpy version is too high and needs to be downgraded. Code: pip install -U numpy==1.11.0 1.11.0 is the version number you want to downgrade to. But I use the latest version of numpy, personally tested pass)

 

Guess you like

Origin blog.csdn.net/weixin_39424706/article/details/127069409