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
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!
Top comments (0)