0

So, I've recently installed pygame and every time I program with it in Visual Studio Code, the .py file runs fine. This is the thing, VSC underlines import pygame with yellow, stating it's an error. It's annoying to me because I can't autofill ANY of the pygame functions. When I click "View Problem", it says "Import "pygame" could not be resolved." Yes, I've tried using venv.

MaxFlyMan
  • 31
  • 3

1 Answers1

0

Make sure you have your init function:

pygame.init()

If you haven't initialized pygame, it's possible that VScode underlines it to warn you.

(Pylance) You could also try to add ./sources in the VScode settings: enter image description here

(Pylint) or go in your .vscode folder in settings.json. Under user settings paste this:

"python.linting.pylintArgs": [
    "--extension-pkg-whitelist=pygame" 
]
krmogi
  • 2,588
  • 1
  • 10
  • 26