Modulenotfounderror: no module named Pygame : ( Solved )

Modulenotfounderror no module named Pygame ( Solved )

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.

Modulenotfounderror No module named pygame
Modulenotfounderror No module named pygame

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
pygame installation with conda
pygame installation with conda

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
pygame installation with source code
pygame installation with source code

 

Thanks 

Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Abhishek ( Chief Editor) , a data scientist with major expertise in NLP and Text Analytics. He has worked on various projects involving text data and have been able to achieve great results. He is currently manages Datasciencelearner.com, where he and his team share knowledge and help others learn more about data science.
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner