VSCode - How to ignore cv2 not recognized by pylint issue (Python + Opencv)

//note: All the configuration in this tutorial is on macOS 10.14.6, but you can solve the issue on Windows 10 too.

By default, after user downloaded python extension in VSCode, and finish configuring python environment (whether Python 2.x or 3.x) .




Also, pip command can work on your computer, first of all, you have to download opencv package using pip3 (command: pip3 install opencv-python)


after installed, type pip3 list and check whether opencv has already been installed.



Okay, and now open VSCode and add a new python file (you can name "test.py" like what I do), copy the sample code below and paste it on your .py file like so:


good, and you will see red wave line warning



but when you run this file by pressing fn + F5 on keyboard, it works!

Now the problem is that how to disable the annoying warning in VSCode ?

It's simple. Just go to VSCode's Preferences -> Settings



then in search bar type "pylint args", you will find the Python Linting option below:



Now hit the blue "Add Item" button, and type "--generate-members" in the text field, and press enter on your keyboard or hit OK to save the configuration.



Now back to the test.py file, which is the opencv sample code I give you, you may see that the red warning is gone, and there you go!



Complete Project download

(many thanks to Alexandre Prevot from Flickr photo. )

留言

這個網誌中的熱門文章

Windows 10 64bits安裝Spyder (Anaconda)

在Spyder IDE 使用Python + OpenCV

Raspberry Pi - 利用AnyDesk遠端到樹莓派,並保持螢幕解析度不縮放