Simply record the installation process of the cv2 library this time.
Opencv installation:
1. Download
Alibaba Cloud Simple Index
University of Science and Technology of China Simple Index
Douban Simple Index
Tsinghua University Simple Index
Simple Index of University of Science and Technology of China
I found it here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
If you are installing for the first time like me, and you don’t know which version to choose, first check your python version.
I installed python3.9 on my computer, so I downloaded this version
2. win+r, then enter cmd to enter the middle end
The installation instructions use: pip install opencv_python
The reason for the failure may be
The version of pip is wrong, then update pip:
If it still doesn't work, try:
pip install opencv-python -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
Note: The URL of the image file here is from aliyun. If it doesn’t work, you can try Tsinghua and other sources. (Because the source of Tsinghua University I started to use was not working, it was successful to replace it with aliyun)
3. Verify after installation
enter python first
Then enter import (if not under python, enter import will definitely prompt that there is no such command)
If there is no problem here, we can start importing the cv2 library in pychrm
Open pycharm, after creating a new project, open the terminal, first go to the folder where the image file we downloaded is located, and then enter the command to install the image file
Click the interpreter setting (environment variable setting) in the lower right corner of the interface
Click on the + sign to add a library
Enter cv2, and then find that there is no, then I enter the installed opencv-python, and it can be used
After entering opencv-python, click the installation in the lower left corner