Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import "pygame" could not be resolved Pylance

I did pip install pygame. When I do pip list, it is installed but when I am trying to import it, it doesn't work.

like image 295
Yakup Mete Mağden Avatar asked Sep 07 '25 04:09

Yakup Mete Mağden


2 Answers

Try:

python3 -m pip install pygame

If you have multiple instances of python, pip may install them under Python 2. Hence the command to ensure you download for Python 3.

Else refer to here. It may be vs-code throwing a false error.

like image 133
Freddy Mcloughlan Avatar answered Sep 09 '25 18:09

Freddy Mcloughlan


If you have selected the right python interpreter, you will need not add the site-packages folder to the Extra Paths.

Have you tried to switch the python interpreter to the right one which you have installed the packages? You can click the Status Bar on the bottom left of the VSCode to switch it. You can refer to the official docs for more details.

like image 44
Steven-MSFT Avatar answered Sep 09 '25 18:09

Steven-MSFT