How to Install Pygame for Python 3.5/3.11
Pygame, as its name shows, is an open-source multimedia library in Python mainly used to make video games that include graphics, sounds, visuals, etc. These days, game programming is quite successful.
It is a cross-platform library that will work on multiple platforms with a single code-base. This library contains a lot of modules for graphics and sounds, as any game is meaningless without sounds or graphics.
Install Pygame in Python 3.5/3.11
Before installing Pygame, you need to make sure that Python 3.x is installed on your system. You can verify this by running the following command in your terminal or command prompt:
python --version
or
python3 --version
If Python is installed, you should see the version number displayed. If not, download and install Python from the official website.
Once Python is installed, you can proceed to install Pygame. There are different methods to do this, depending on your operating system.
For Windows Users:
- Open your command prompt and type the following command:
pip install pygame
or
python -m pip install pygame
For macOS Users:
- Open Terminal and type the following command:
pip3 install pygame
or
python3 -m pip install pygame
For Linux Users:
- Open Terminal and type the following command:
sudo apt-get install python3-pygame
Verify Installation
After the installation is complete, you can verify that Pygame has been installed successfully. Type the following command:
python -m pygame.examples.aliens
or
python3 -m pygame.examples.aliens
This should run a simple game demo provided by Pygame, confirming that the installation was successful.
Or, you can use the pip list
command.
pip list
If you found Pygame in the list, it is successfully installed.
I am Fariba Laiq from Pakistan. An android app developer, technical content writer, and coding instructor. Writing has always been one of my passions. I love to learn, implement and convey my knowledge to others.
LinkedIn