Monday, June 13, 2016

Installing PyGame with Python 3.5 on Windows 10

Quick installation notes for PyGame with Python 3.5 on Windows 10 since the available installers didn't work for me, the symptom being the apparently highly frequent "pygame module has no attribute init" error when trying to call pygame.init() after importing pygame.

First if you've run any PyGame installers previously, make sure to clean up anything they installed. The easiest way to do this is to run the installer again and choose the uninstall option, but you may also want to check the Lib/site-packages directory under your Python installation to make sure there aren't any remnants.

Next, go here and download the appropriate .whl file for your environment.

Next, open a command prompt and run:
pip install wheel

Finally, browse to the directory where your downloaded .whl file is located and run:
pip install pygame_file_name_here.whl

Restart your command prompt to be safe, and at that point you should be able to do this in a Python interpreter without getting errors:
import pygame

Hope that saves someone else some head against desk time.

No comments: