Jan 20, 2009. For Mac OS X, download the.zip or.dmg file for the version of Python you have and run it. For Linux, open a terminal and run “ sudo apt-get install python-pygame ”. On Windows, double click on the downloaded file to install Pygame.
Pygame on OS X Leopard
Tonight I wanted to start a new Pygame project to learn basic game development. I thought this would be rather easy, but apparently I’m not the only one who has had trouble.
Attempt 1 – Macports
Reading the Pygame download page I notice that it mentioned Macports. So I fired up Terminal, typed in
sudo port install py-game and then waited about 5 mins for it to download and build everything.
Time to try it out.
Not cool. A little bit of searching and I found that for some reason Macports installed pygame under
/opt/local/lib/python2.4/site-packages/pygame . This might be good if you use the Macports python but clearly not suitable for the default pre-installed Python 2.5.
As a last ditch effort to use the Macport Pygame I tried copying the
/opt/local/lib/python2.4/site-packages/pygame into /Library/Python/2.5/site-packages which resulted in a whole heap of Python C API version mismatch warnings.
Oh well,
rm -rf /Library/Python/2.5/site-packages/pygame
Attempt 2
Ok, time to try the pre-compiled installers.
I downloaded the OS X 10.5 installer from the Pygame downloads. However when I ran it, on the select destination screen it kept telling me that my startup volume was not acceptable as “System Python 2.5 is required”. Yet python was clearly running
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
I installed the Python package linked to on this page. I’m not sure what the package does that the default Python didn’t, but others were recommending it worked for me as well.
Then I ran the Pygame installer again and all was good. That is, until I tried importing pygame again.
So back to the Pygame downloads page to grab pyobjc-1.4-py2.5-macosx10.4.mpkg.zip. Don’t be put of by the 10.4 in the filename – this is the one you want. The installer completed without troubles, and I could finally import pygame properly.
The Instructions
Without the waffle.
What should have been five minutes, was more than 30 minutes of hassle. Now, time to start writing my game.
January 20, 2009 at 11:53 am4 comments
Here is a quick tutorial on how to get Pygame up and running with Python 3 on a Mac with OS X 10.6.
Rationale
The Pygame download site presently has packages for Python 2.4, 2.5, 2.6 and 2.7 for OS X, but none for Python 3 (3.2 to be precise). This is odd, as everyone is doing Python 3 development these days, don't you think? And there even is an installer for Python 3 on MS Windows. So, let's change that and get Pygame working with Python 3 under OS X.
Prerequisites
Make sure the thing in front of you is an Apple computer with an OS X operation system. I my case it was a MacBook Pro with OS X 10.6.6 'Snow Leopard'.
You will need XCode, the Apple developer toolset. For OS X 10.6 'Snow Leopard', you will find it on the installation DVD under 'Optional Packages' or similar. For OS X 10.7 'Lion' you can download XCode for free in Apple's App Store.
To learn about your computer's operating system version, click the apple symbol in the top left and select the first menu item 'About This Mac'.
Get A Package Manager
Next, get a decent package manager to be able to conveniently install dependencies. I used Homebrew, and so should you. In the Finder, go to Applications -> Utilities and start the Terminal. To install Homebrew, type
and hit Return.
Install Python 3
Homebrew has a recipe for Python 3, which we are going to use. Type
and hit Return. Once that is done, verify the Python version by typing
Install Pygame
The following is taken from a Pygame Issue Tracker thread.
First install the Mercurial version control system:
Then do the same for the git version control system, which is needed by a dependency package:
How To Download Pygame
Now install all the dependencies of Pygame:
Almost there! To install Pygame now, we will use pip. Go and get it by running:
And now, finally:
Pygame Download Mac Os Xp
After this is done, verify that it is working:
That's it! Now you have Pygame for Python 3 installed and working and can start hacking.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |