Modulenotfounderror: no module named Pygame error occurs when the module Pygame is not installed properly before invoking into the code. Sometimes we install the Pygame module but either the package manager ( pip, conda, etc ) is misconfigured or Pygame has permission related issues while installation. In such scenarios, we encounter this modulenotfounderror. Well, The best and easy way to fix this error is to reinstall the package. In this article, we will explore multiple ways to install or reinstall pygame module.
Modulenotfounderror: no module named Pygame ( Solution Approaches) –
We can use a package manager or source code to install the package. Well, using a package manager like pip, etc is much easier than going with the source code itself. Let’s start with pip.
Approach 1: Pygame Installation with pip package manager –
If you want to install the latest version of Pygame then use the below code.
pip install pygame
The best part with pip pygame installation is it provides multiple options to control versions, permission access, etc in very minimal change in installation command. Let’s explore them.

1. Suppose you do not want to install the latest version of pygame because of some existing incompatibility then you can provide the version along with the command. Here is the way for this.
pip install pygame==2.1.1
2. Providing admin rights with commands is simple—all we need to add sudo keyword with command.
sudo pip install pygame==2.1.1
Approach 2: Pygame Installation with conda package manager –
Conda is simple just like the pip package manager for Pygame installation. But My personal preference is pip over conda. Because it gives multiple option for alternative configurations.
conda install -c cogsci pygame

Approach 3: Pygame Installation with Source code –
If you want to install the Pygame module from the source code then we need to first download it. Then we need to run the below command.
python setup.py install

Thanks
Data Science Learner Team
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.