This is the code I have:
import pygame
pygame.init()
I\'m very confused because if I try to run the file, then there seems to be no issue,
I had the same issue when I started using Visual Studio Code with Python. It has nothing to do with having another pygame.py or not installing it properly. It has to do with the fact that Visual Studio Code takes your code literally, and since you cannot import pygame.init()
, it thinks that it isn't a correct module.
To fix this, open up settings.json (go into your settings, and click the {}
icon) and paste
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame"
]
to it.