VSCode WxPython package intellisense "Module 'wx' has no 'Frame' member"
Answer a question 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 =
Answer a question
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!
Answers
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"],
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.)
更多推荐
所有评论(0)