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"],

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.)

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐