简体   繁体   中英

VS code module pygame has no init member

I wanted to learn pygame so I downloaded it into VS code and began coding. As you know one of the first things you have to do is import pygame and after that pygame.init() when i did that there was an error saying pygame has no init member.The message pops up with some pygame functions such as pygame.quit(), but not with other ones such as pygame.time.Clock(). I looked online for answers and found some post that told me to add something to settings.json - when I did nothing had changed, I tried a couple of these but none of them seem to work. From what I understand, I should be able to run the code, it's just that the messages are annoying.

When I used the module " pygame ", I reproduced the problem you described:

(Although the code can be executed, there is an error "no init member")

在此处输入图片说明

Solution:

Please add

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

in " settings.json ", and use the latest version of VScode.( Version: 1.50.1 )

result:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM