Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import pygame in visual studio code?

I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be imported in visual studio code).

like image 812
Haniyeh Avatar asked Dec 13 '22 13:12

Haniyeh


2 Answers

Here is the solution I tried:

From left bottom of your vs code you can find python environment, you can in the image I marked red:

enter image description here

after clicking in the red marked area you can see below option to select:

enter image description here

from the option select your desired one. Suppose first i was try selecting 2nd one but it was not working then i tried with the last one and it worked.

like image 150
Md Nakibul Hassan Avatar answered Dec 27 '22 11:12

Md Nakibul Hassan


  1. Open the terminal of Vscode.
  2. Type pip install pygame or pip3 install pygame.
  3. Import pygame and enjoy it.
like image 21
Mohamadreza Kariminejad Avatar answered Dec 27 '22 09:12

Mohamadreza Kariminejad