I'm trying to learn pygame and am having trouble getting it to work. (I'm using python 3.8.5 64 bit) First I installed pygame with python3 -m pip install -U pygame --user
and that worked fine and I could type import pygame
with no errors. The next line, pygame.init()
, gave me an error though. The error was Module 'pygame' has no 'init' memberpylint(no-member).
I went to this link for a solution Why does it say that module pygame has no init member? And found one which was to paste "python.linting.pylintArgs": ["--extension-pkg-whitelist=lxml"]
into .vscode>settings.json
but this didn't make the errors go away (yes I saved both files). The real confusing part to me though is that the code works how I want it to (to make a new, blank window for the game and close with the red x in the top right) even with these errors. I think every time I call a method from pygame I get an error even if the methods working and I just want to make sure leaving it how it is won't break things in the future.
print(pygame)
gets me
<module 'pygame' from 'C:\\Users\\jgood\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\pygame\\__init__.py'>
dir(pygame)
gets me
pygame 1.9.6
Finally here is the code
#where most python goes
import pygame
#initating our pygame stuff won't work without this line
pygame.init() <--- Module 'pygame' has no 'init' memberpylint(no-member)
#create screen like html document.getelementbyid.ect.ect
screen = pygame.display.set_mode((800, 600)) # this takes two args height and width in pixels
running = True # flag
#game loop
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT: <----- Module 'pygame' has no 'QUIT' memberpylint(no-member)
running = False
and here is my settings.json
file
{
"python.pythonPath": "C:\\Users\\jgood\\AppData\\Local\\Microsoft\\WindowsApps\\python3.8.exe",
"python.linting.pylintArgs": ["--extension-pkg-whitelist=lxml"]
}