Search code examples
pythonvisual-studio-codewxpython

VSCode WxPython package intellisense "Module 'wx' has no 'Frame' member"


I'm trying to use WxPython by writing a simple script on VSCode. I'm using the default Python extension (which has an intellisense) plus Kite. My code is as follows:

import wx

app = wx.App()

frame = wx.Frame(None, title='Simple application')
frame.Show()

app.MainLoop()

It runs perfectly, but the problem is that VSCode tags "wx.Frame" as error and says:

Module 'wx' has no 'Frame' memberpylint(no-member)

I have no idea why that happens, and this is annoying me. Any information about why that happens?

Also any suggestion on how to suppress this error message would be welcome!

Thanks!


Solution

  • This information is provided by Python's code analysis tool Pylint.

    Reason: For security reasons, Pylint only trusts C extensions from the standard library stdlib by default, but the module "wxPython" does not come from it.

    So we can deal with it in the following two ways:

    method 1: (Add it to the whitelist)

    Please add the following settings in settings.json:

    "python.linting.pylintArgs": ["--extension-pkg-whitelist=wx"],
    

    enter image description here

    method 2: (Turn off this notification)

    Since it does not affect the execution of the code, we can use "python.linting.pylintArgs": ["--disable=E1101"], in settings.json file to turn off "no-member" notifications. (It is recommended that you turn off Pylint notifications after the code can run successfully.)