UPDATE: Apparently, this is no longer necessary. As of February, 2017, you can just run
pip install pygame
and it will install the right version of pygame for your environment.
I’m not a game developer, but I’ve been playing with Pygame lately and have been impressed. I plan to use it in one of our Python courses to teach object-oriented programming. I use 64-bit Windows 8, so I have the 64-bit version of Python 3.4. Most of our students are unlikely to be game developers, but because games have obvious visible objects, they provide a nice framework for teaching OOP.
Unfortunately, Pygame doesn’t have an official 64-bit installer, so they recommend you use the 32-bit version of Python. So, I installed the 32-bit version of Python alongside the 64-bit version I already had, but that was a pain as I had to constantly make sure I was running the right one. It also made the 32-bit version the default.
Luckily, Christoph Gohlke of the University of California, Irvine has made a bunch of 64-bit binaries available for Python extension packages, including one for pygame.
The installation file is a wheel file, which can be pretty tricky to install. The documentation is a bit weak, so I’ve laid it out here.
Note that these instructions assume you already have a 64-bit version of Python installed.
To install the Windows 64-bit version of Pygame, which is the only version that will work with the 64-bit version of Python, follow these steps:
- Make sure that your Path variable includes both your Python directory and the Scripts directory:
- Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
- Click pygame 1.9.2a0 cp34 none win_amd64.whl (for Python 3.4):
- Save the file locally. Do not rename the file as the file name structure is important.
- Wheel (.whl) files are installed using pip and wheel. So before installing the wheel file, you need to make sure you have an up-to-date version of pip and of wheel. To do this:
- Click the Windows icon and select Run:
- Type “cmd” in the Run prompt and press OK:
- PIP is used to unpack wheel files. At the prompt, type “python -m ensurepip”:
- If it tells you the requirement is already satisfied, run the upgrade command: “python –m ensurepip –upgrade”:
- Install wheel. At the command prompt, type “pip install wheel”:
- If it tells you the requirement is already satisfied, run the upgrade command: “pip install wheel –upgrade”:
- Click the Windows icon and select Run:
- Now you’re ready to install pygame 1.9.2a0 cp34 none win_amd64.whl. At the command line, make sure you’re in the same directory as the .whl file and then type “pip install pygame-1.9.2a0-cp34-none-win_amd64.whl”:
If you get an error saying the file name does not exists, it’s likely because you’re running thepip install
command from a different directory. Either use navigate to the correct directory (reference) and run the command again or run the command using a full absolute path (e.g., “pip install c:\users\nat\pygame-1.9.2a0-cp34-none-win_amd64.whl”).
Have fun making games with pygame!
No comments:
Post a Comment
Thanks for your comments