Problem background:
If you have tried many methods of installing opencv in Anaconda and it doesn't work , then this method in this article can fundamentally solve this problem.
Installation preparation:
The python in Anaconda3 is recommended to be version 3.6 , and the installed opencv is preferably the corresponding version 3.4.1.15 . The installed opencv files are two, and the latter is the opencv expansion library (opencv_python-3.4.1.15-cp36-cp36m-win_amd64. whl, opencv_contrib_python-3.4.1.15-cp36-cp36m-win_amd64.whl). If your system is 32-bit, please select the corresponding version of the file to install.
For the corresponding relationship between Anaconda3 and python versions, please refer to this blogger’s article: the download address of opencv_python-3.4.1.15 of each version and the download address
of version 64 of opencv_contrib_python-3.4.1.15, and the download address of other versions of opencv_python
Installation process:
first step
Create a new folder and save the downloaded opencv file in it. (Example: D:\001Major\CVMV\OpenCV)
second step
Click anaconda3 in the start menu, find the prompt (as shown below) and open it.
The location displayed at this time is the C drive (an environment created by the original anaconda itself)
input
D:
Enter the D disk area (my anaconda and opencv are installed on the D disk, if you install it on other disks, you can change it yourself)
third step
Then enter cd plus your anaconda installation path, for example
cd 001Major\CVMV\Anaconda3\jupyter
At this point enter the installation location of anaconda
the fourth step
Enter pip install "the save path of opencv downloaded by yourself in the first step and the file name of opencv (including the suffix name)" (remember the double quotes) for example
pip install "D:\001Major\CVMV\OpenCV\opencv_python-3.4.1.15-cp36-cp36m-win_amd64.whl"
After running, it will show that the installation is successful.
In the same way, to install opencv_contrib_python, you only need to change the file name.
Result test:
Click on anaconda3, find the prompt (as shown below) and open it, enter
python
enter
import cv2
If it can run, it means that the installation of opencv is successful.
Look at the version and enter
cv2.__version__
Note: There are two short underscores before and after
OK, the installation is over!