python-3.xopencv

cv2 python has no imread member


I pip installed OpenCV-python. The installation seems to be fine and I tested it out on the python IDLE. It ran without any problems. I've been trying to run it on VS Code but it doesn't seem to work. The autocomplete recognizes the imread function but when I type it in it throws up an error saying cv2 has no imread member. I am using the most updated version of python

I am calling it like this:img2 = cv2.imread("C:\Biometric\min.jpg", 0)


Solution

  • Since you are trying to executing this with VS Code, try following steps

    1. Open palette on VS Code (use specifies command): CTRL + Shift + P
    2. Then select "Preferences > Open Settings (JSON)" option in the palette dropdown
    3. Then add the following line in the opened settings.json file python.linting.pylintArgs": ["--generate-members"]

    this must work