After typing import cv2 in the python file
the error is
Traceback (most recent call last):
File "C:/Users/郑安学/PycharmProjects/pythonProject3/task1.py", line 1, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
After searching, there are the following problems
1. The parent package of cv2, opencv-python, should be imported.
2. the computer is affected by the virtual environment because it has downloaded Anaconda.
3. there are multiple versions of python on the computer, so the path to the package is affected by multiple downloads and uninstallations
So we need to specify the intepreter path to download cv2 package
First of all, find the download path of cv2
Get the path to cv2
Copy this section
Then in the settings find
Show All
Click on the
Click on the circle, click ➕ Add interpreter paths, and paste the copied paths into it
apply
————————————————
原文链接:https://blog.csdn.net/EchoAnnnn/article/details/126523073