Pygame is an open source cross-platform Python module used for designing and scripting video games.
Pygame can be a great module to use on a device like Raspberry Pi.
I tried using Pip
to install Pygame, but that did not work, here is the right way to get it installed on Fedora.
Pygame is available as a package in Fedora’s repository.
I ran a search and here is my result.
[darryl@linuxbox ~]$ dnf search pygame
Last metadata expiration check: 0:10:16 ago on Mon 18 May 2020 11:02:17 PM EDT.
====================== Name & Summary Matched: pygame =======================
pygame-devel.i686 : Files needed for developing programs which use pygame
pygame-devel.x86_64 : Files needed for developing programs which use pygame
=========================== Name Matched: pygame ============================
python3-pygame.x86_64 : Python3 modules for writing games
[darryl@linuxbox ~]$
Code language: PHP (php)
In the repository Pygame is a Python 3 module. We can install by running the installation command.
sudo dnf install python3-pygame
Below is the dependencies dnf
will download and install.
[darryl@linuxbox ~]$ sudo dnf install python3-pygame
Last metadata expiration check: 0:05:52 ago on Mon 18 May 2020 11:08:33 PM EDT.
Dependencies resolved.
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
python3-pygame x86_64 1.9.6-7.fc32 fedora 2.9 M
Installing dependencies:
SDL x86_64 1.2.15-43.fc32 fedora 213 k
SDL_image x86_64 1.2.12-23.fc32 fedora 44 k
SDL_mixer x86_64 1.2.12-19.fc32 fedora 95 k
SDL_ttf x86_64 2.0.11-17.fc32 fedora 25 k
fluidsynth x86_64 1.1.11-7.fc32 fedora 25 k
fluidsynth-libs x86_64 1.1.11-7.fc32 fedora 209 k
gnu-free-fonts-common noarch 20120503-22.fc32 fedora 122 k
gnu-free-sans-fonts noarch 20120503-22.fc32 fedora 782 k
jack-audio-connection-kit x86_64 1.9.14-2.fc32 fedora 534 k
libffado x86_64 2.4.1-10.fc32 fedora 901 k
libgfortran x86_64 10.1.1-1.fc32 updates 823 k
libmikmod x86_64 3.3.11.1-8.fc32 fedora 154 k
libquadmath x86_64 10.1.1-1.fc32 updates 197 k
libxml++ x86_64 2.40.1-10.fc32 fedora 103 k
openblas x86_64 0.3.9-2.fc32 fedora 30 k
openblas-threads x86_64 0.3.9-2.fc32 fedora 4.5 M
portmidi x86_64 217-32.fc32 fedora 31 k
Installing weak dependencies:
python3-numpy x86_64 1:1.18.4-2.fc32 updates 4.4 M
Transaction Summary
=============================================================================
Install 19 Packages
Total download size: 16 M
Installed size: 78 M
Is this ok [y/N]:
Code language: JavaScript (javascript)
We can now run import pygame
to check if it is working correctly.
[darryl@linuxbox ~]$ python3
Python 3.8.2 (default, Feb 28 2020, 00:00:00)
[GCC 10.0.1 20200216 (Red Hat 10.0.1-0.8)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
>>>
Code language: JavaScript (javascript)
The below response is what you should get when you run import pygame
.
>>> import pygame
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Code language: JavaScript (javascript)
Done, now you can code games with the pygame
module, I would love to see what you developed.
Happy coding!