I am trying to use opencv in my code. It works fine when I run it directly from spyder or from command prompt using import cv2
.I have a small code in file 'test_opencv_installation.py' that contains import cv2
as following
import cv2image = cv2.imread("logo.png")gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)cv2.imshow("OpenCV logo", image)cv2.imshow("OpenCV logo gray format", gray_image)cv2.waitKey(0)cv2.destroyAllWindows()
However, The following error occurred when running the file "C:\Anaconda\envs\my_opencv\test_opencv_installation.py"
:
The module 'cv2' could not be found or imported.
This is the full error message:
Traceback (most recent call last):File "C:\Anaconda\envs\my_opencv\test_opencv_installation.py", line 6, in <module>import cv2ModuleNotFoundError: No module named 'cv2'
Please share your experience and kindly suggest me any solution to this.Thanks....