The Artful Scientist

Communicating the greatest possible growth

  • Google Talk

  • Skype Me

    My status
  • Where are you?

    Welcome to theartfulscientist. Enjoy your stay as I talk about my life as a fire protection engineering student and one who studies fire dynamics. These posts range from day to day excitement to my developmental life and provide a window into my world.



    The about page tells more.
  • Photo Albums

  • Want to read what I read?

    Visit my Google Reader shared items page. You can even subscribe to my favorite shared articles.
  • My Music Plays


  • My Visited US States

    Visited US States


    • Subscribe

        RSS Subscribe

      or subscribe to updates by email:

    • Search This Blog

    • Archives

    •  

      March 2008
      M T W T F S S
      « Feb   Apr »
       12
      3456789
      10111213141516
      17181920212223
      24252627282930
      31  

    How to install PyObjC, pygame, and gasp on Mac OS X for Python tutorial

    Posted by Kris on March 16th, 2008

    I am going through the Python tutorial “How to Think Like a Computer Scientist” right now, and it is an excellent source for beginner/intermediate Python hands-on learning.

    http://openbookproject.net/thinkCSpy/

    However, when I got to chapter 8, my fun stopped right away. The author refers to a Python library called GASP (Graphics API for Students of Python) and gives an example and case study of a small game. The thing is, he doesn’t tell you how to install the module and it abruptly interrupts your lovely Python learning experience.

    http://openbookproject.net/thinkCSpy/ch08.xhtml

    I tried to use easy_install to install most of these, and it always ended up failing for some reason or another.

    As I am using Mac OS X Leopard, I will provide the missing instructions for how to get the gasp module installed (and its dependencies) for anyone else who runs into this situation:

    How to install PyObjC, pygame, and gasp on Mac OS X

    1. I assume that you have already installed some version of Python; I am using Universal Python 2.5 from http://www.pythonmac.org/packages/ which is a nice, easy-to-install package and has other prebuilt packages like numpy, wxPython, matplotlib, etc. ready to be installed. You can see other ways to get Python on your Mac at http://wiki.python.org/moin/MacPython/PythonDistributionsForMac
    2. You will need to install PyObjC, which is also available as a package from http://www.pythonmac.org/packages/ under the 2.5 link.
    3. Now, you will install pygame from a package (pygame-1.8.0rc4-py2.5-macosx10.4.mpkg.zip) available at http://rene.f0o.com/~rene/stuff/macosx/. This is linked from http://www.pygame.org/download.shtml
    4. Finally, we get to the part of installing gasp, which is confusing to find in itself. The FAQ page is at https://answers.launchpad.net/gasp-code/+faq/42 but the link to download is wrong. Get it from https://launchpad.net/gasp-code/+download. You will want to download the Code Release which is currently called python-gasp-0.1.1.tar.bz2.
    5. Extract the bz2 file and there will be a folder inside called gasp. Copy this folder to the /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ directory and you will be in business!

      This is the command that I used: sudo cp -R ~/Desktop/python-gasp-0.1.1/gasp/ /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/gasp

    6. Open a python session and type import pygame and import gasp to make sure that they are installed correctly.
    7. Carry on with the great tutorial linked above!

    I found it odd that the beginners tutorial left out all of this information. Hopefully this will save someone the two days that it took me to find all of these links, packages, and methods.

    Related posts:

    1. The Golden Resource List for Python Beginners
    2. The clarity of Python vs. the cloud of Perl
    3. Mac-Corrected Numerical Analysis Fortran Programs
    4. Updates on welcomed unstability

    4 Responses to “How to install PyObjC, pygame, and gasp on Mac OS X for Python tutorial”

    1. jde Says:

      Hello, thanks for posting the installation instructions for gasp! I’ve been following “How to Think Like a Computer Scientist” online book. When I try to run the pitch.py code I get the following error:

      Traceback (most recent call last):
      File “/Users/JonathanEricson/Desktop/pitch.py”, line 80, in
      set_speed(120)
      NameError: name ’set_speed’ is not defined

      Basically a window with a yellow background pops up, and then nothing happens after that. Gasp imports in the Python shell just fine, so I’m not sure why set_speed is not defined if it is part of gasp.

      Pardon my failure to use the appropriate CS vernacular — I’m new to this…

      Thanks!
      Jon

    2. Kris Says:

      Hey, thanks for the comment.

      You know, after all of that trouble that I went through installing gasp, I got those same errors as you. So I emailed the author of “How to Think Like a Computer Scientist” and asked what he thought of the errors. Based on his response and what I found in recent gasp discussion, it looks like gasp is rapidly changing and those methods like set_speed and frames are not being used in the gasp code anymore. So this means that the book is a bit out of date with that example. At this point, I also get gasp to import but have the same yellow screen as you.

      Anyway, the author of the book says that a lot of development has been going on with gasp, and that we should wait for the next big release of gasp which should be coming *soon* and that he is also adding another chapter to the book which uses gasp. In the meantime, it looks like gasp 0.2.0beta1 is available, but the 0.1.1 release is still there.

      After all that, for now I would just skip the chapter and wait for the new updates - and in the meantime you can view my other post here: http://www.theartfulscientist.com/2008/03/17/the-golden-resource-list-for-python-beginners/ for more resources to learn Python and *lots* of places to go for challenges/exercises/practice. :)

      Happy Pythoning!

      - Kris

    3. Niels Olson Says:

      I’m going through the same book. Definitely a great place to start. A couple of notes on the instructions above:
      1) the PyObj package is actually PyObjC
      2) the command above is correct. The casual reader should pay attention to the fact that the command actually copies the inner folder gasp, not python-gasp-0.1.1

    4. Kris Says:

      @Niels Olson

      1) Whoops, thanks for the catch. Corrected.

      2) I stated that was my command because depending on which distribution of Python you installed, that packages path may be different.

      Thanks for the notes!

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>