Installing and importing the Pygame module in Vscode

Asked

Viewed 2,103 times

0

I am learning to program python through Vscode and found it difficult to import the pygame module.

import pygame
pygame.init()
pygame.mixer.music.load('nomedamusica.mp3')
pygame.mixer.music.play()
pygame.event.wait()

The message I get is: Modulenotfounderror: No module named 'pygame'

I tried to install the module through IDLE Python using the

python -m pip install pygame

and gave Invalid Syntax

Which way should I go to install this module and any other module?

1 answer

0


You should install the package via terminal and not in IDLE. Open your system terminal and type in what you were trying to:

python -m pip install pygame

If different versions of Python are installed use python for python 2 or python3.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.