I currently have Python 3.10.5 and pygame 2.1.2.
VScode 1.70.2
Versions
For some reason there is the following warning: Image for warning
Import "pygame" could not be resolved PylancereportMissingImports
Even though I have the pygame library installed using "pip install pygame".
And when I run the file by pressing the "Run Python File" in the right top corner, it runs perfectly without an error. It even uses the terminal to show whatever I am printing.
My issue here is the warning and that intellisense for pygame isn’t working.
What can I do to fix that.
I already tried to make a clean install on everything, python, pygame, even VScode. Nothing.
2
Answers
Try to reload vscode (by command pallete or just restart the app), reinstall pygame and make sure python path is selected. Also it is worth to trying selecting interpreter. Open command pallete and type: Python: Select Interpreter, then select your python version.
yes as the @NoBlockhit stated probably you have 2 different python versions installed and vs code choses the one without the pygame library (https://code.visualstudio.com/docs/python/environments) if you scrolldown it shows you how to chose an in interpreter…