OpenCV with Python error

1st, I used Visual Studio Code IDE
I have successfully installed OpenCV 4.1.1 at Python 3.7.0.

  1. import cv2

  2. .

  3. print(cv2. version )

I run the ""import cv2

and the following error message comes out.
PS C:\Users\hlaky\Desktop\My_Project>
PS C:\Users\hlaky\Desktop\My_Project> & “C:/Programs Files/Python37/python.exe” c:/Users/hlaky/Desktop/My_Project/

Please help me to correct this error.

am not an expert at cv2 but try:


from cv2 import *

img= cv2.imread(‘name of the image’, 0)


Looking carefully at your screen caps, it almost appears you are not using “normal” single quotes around “lena.jpg” - they look like the typographic quotes you can get with Microsoft Word.  This is corroborated by the squiggly under the code in the screen shot - the editor things something is wrong.

[I may be confused by your font choice in the editor.]

You can use either single quotes or double quotes with python strings. So try replacing 




And in any case, use the “plain” single or double quotes [Ascii codes 39 and 34, respectively] whenever writing code.