Modulenotfounderror no module named ‘pygame’

In this article, we will learn the solutions on how to solve the Modulenotfounderror no module named ‘pygame’.

Furthermore, the no module named ‘pygame’ error appears only if you did not install the pygame or either it was installed in the wrong environment.

What is Pygame Module?

The pygame module produces functionality to make a graphical display, work with graphics, and read from input devices.

For example, the mouse and keyboard are on different platforms.

Also read: Modulenotfounderror: no module named skimage [SOLVED]

How to solve the Modulenotfounderror no module named ‘pygame’?

Time needed: 3 minutes

Here are the multiple solutions to solve the no module named ‘pygame’ in python 2, python 3, windows, Ubuntu, CentOS, and openSUSE.

  • Solution 1: Install in Python 2

    The following command to install the pygame in python 2:
    pip install pygame

  • Solution 2: Install in Python 3

    This is the command to install the pygame in python 3:
    pip3 install pygame

  • Solution 3: Install Get permissions error

    If you get permissions error, type this command for the installation:
    sudo pip3 install pygame
    or
    pip install pygame –user

  • Solution 4: Install PIP in Path Environment Variable

    Type this command for the installation of pip in your path environment variable:
    python -m pip install pygame

    For Python 3:
    python3 -m pip install pygame

  • Solution 5: Install py alias (windows)

    This is the command to install in py alias:
    py -m pip install pygame

  • Solution 6: Install for Ubuntu/Debian/Mint

    This is the command to install in ubuntu, Debian and mint:
    sudo apt-get install python3-pygame

  • Solution 7: Install CentOS/Fedora/Red Hat

    The command to install CentOS, fedora and hat:
    sudo yum install python3-pygame

  • Solution 8: Install for openSUSE

    The command to install for openSUSE:
    sudo zypper install python3-pygame

  • Solution 9: Install for arch/Manjaro

    This is the command to install in arch or Manjaro:
    sudo pamac install python-pygame

  • Solution 10: Install for Jupyter Notebook

    This is the command to install in Jupyter Notebook:
    !pip install pygame

Conclusion

To conclude, if ever you had encountered this error Modulenotfounderror: no module named ‘pygame’. Then the above solutions are the best way to solve your error.

Leave a Comment