After many detours , I find , In the use of anaconda install OpenCV when , It is easy for the server not to respond , After all, across the wall , While using domestic , Such as anaconda When installing Tsinghua source , Some servers will not respond , Cause installation to fail .、
And if you use pip install , There is no way to solve the dependency problem , Direct installation OpenCV The result is still failure .
After trying many ways , I finally found a more reliable way .
Reference link : Zhihu tutorial
But there are still some problems when using this method , That is the lack of VideoCapture This library that calls the camera . Therefore, we still have to solve the problem of dependency , Install some dependency packages .
ad locum , I'm ready , Include OpenCV And some dependent packages , Click here to jump directly download
After downloading, unzip , Then open the Windows Medium cmd, Shortcut :win+R After the key , Input cmd And then go back .
Then use the command to go to the directory where the installation package is located . For example, mine is E Under the plate , Then I can transfer the directory to that folder in the following way .
Is the disk where the input file is located , I was in E disc , Then type in E:, And then go back , And then use cd command , I was in E On the plate python Under the folder opencv Folder , So you can use this method . Of course , If you are afraid of losing wrong , You can use copy and paste , You can also use tab Key completion , That is, first input a few words or letters in front of the file , Then press tab Key can be automatically supplemented .
After installation anaconda after , You can use pip Command to install the third-party library . The documents here are only applicable to python3.7 Of , That is to say, it must be installed anaconda3 Can only be .
Use... Sentence by sentence on the command line pip install Command to install , It's still recommended to use tab Key to complete the file name , however pip install This command must be typed by hand or copied and pasted .
pip install opencv_python-3.4.9.33-cp37-cp37m-win_amd64.whl
pip install VideoCapture-0.9.5-cp37-cp37m-win_amd64.whl
pip install Pillow-8.0.1-cp37-cp37m-win_amd64.whl
Enter every time you type a sentence , And you must see the prompt of successful installation .
If all installations are successful , Then you can refer to another article about haar Face detection article to test opencv.
That is, you will be prompted during the installation , As shown in the picture below , Just check the two .
If you don't see any python The name of the plug-in , You can also search for the installation .
Of course ,vscode It also supports simplified Chinese , Similarly, you need to install plug-ins .
After installation, you only need to restart vscode This software can be converted into a simplified Chinese interface .
Of course , To verify your python Whether the environment can be used , It is recommended to run one randomly python Program to test .