Hi,
I hope someone can help me.
My son is really interested in learning game programming in Python. I've tried Spyder but cant get Pygame installed.
Any suggestions on what I can use that I can just download and install without the need for additional modules to be added.
He is using Ubuntu 18.04
Appreciate any comments or feedback
Thanks
Gary
What errors did you get while installing pygame? Can you copy/paste the messages you get when running pip install pygame
?
pip install pygame
works but when I try to run some basic code that uses the pygame module I get this error
ModuleNotFoundError: No Module Named 'pygame' on line 2
I am using Spyder (Python 3.6) on Ubuntu 18.04
Here is the code I'm trying to run
# Pygame template - skeleton for a new pygame project
import pygame
import random
WIDTH = 360
HEIGHT = 480
FPS = 30
# define colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
# initialize pygame and create window
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
# Game loop
running = True
while running:
# keep loop running at the right speed
clock.tick(FPS)
# Process input (events)
for event in pygame.event.get():
# check for closing window
if event.type == pygame.QUIT:
running = False
# Update
# Draw / render
screen.fill(BLACK)
# *after* drawing everything, flip the display
pygame.display.flip()
pygame.quit()
From command line.
pip -V
pip3 -V
Dos
pip3
point to 3.6:
pip3 install pygame
Problem finding pip3.
sudo apt install python3-pip
Also look
pyenv Simple Python Version Management can make easier in future to upgrade and use other versions.
Success!!! Thanks a million