PyLint not recognizing cv2 members

后端 未结 6 867
忘掉有多难
忘掉有多难 2020-12-01 03:15

I am running pylint on an opencv project and I am getting many pylint errors in VS code about members not being present.

Example code:

import cv2
cv         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 03:58

    This is from pylint. You can generate a pylint config file in the root of your project with this command: (I find this to be helpful if you work in a team or on different computers from the same repo)

    pylint --generate-rcfile > .pylintrc
    

    At the beginning of the generated .pylintrc file you will see

    # A comma-separated list of package or module names from where C extensions may
    # be loaded. Extensions are loading into the active Python interpreter and may
    # run arbitrary code.
    extension-pkg-whitelist=
    

    Add cv2 so you end up with

    # A comma-separated list of package or module names from where C extensions may
    # be loaded. Extensions are loading into the active Python interpreter and may
    # run arbitrary code.
    extension-pkg-whitelist=cv2
    

    Save the file. The lint errors should disappear.

提交回复
热议问题