DEV Community

Cover image for Installing Pygame
Vivian Dai
Vivian Dai

Posted on

1

Installing Pygame

Pygame can be somewhat difficult to install for a beginner so here are scripts that can install Pygame more easily (download the right file for your operating system then double click on the file):

:: A script to install pygame for Windows
:: download this script and run ./installpygame.bat
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install pygame
del /f get-pip.py
# An easy script to install pygame for Linux and Mac
# download this script and run ./installpygame.sh
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
python3 -m pip install -U pygame --user
rm get-pip.py

It's preferable if the user has admin permissions.

Other Common Problems

Naming a File pygame.py

naming file error

AttributeError: module 'pygame' has no attribute 'init'

This kind of problem occurs when there is a file in the same folder as the file you're trying to run called pygame.py. When importing, Python will first check the files in the folder to see if there's a module written by the user before checking elsewhere—basically don't name files pygame.py

Conclusion

Hopefully this made it easier to install Pygame, happy coding!

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay