Installing Pyglet in Mac OS X

Pyglet is a common requirement for many Python applications, a major one being Cocos2D.

But it doesn’t work out of the box. Running a Pyglet application will result in the following error:

OSError: dlopen(/System/Library/Frameworks/QuickTime.framework/QuickTime, 6): no suitable image found.  Did find:

/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture

/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture

The following are the steps to take to get Pyglet and PyObjc installed on OS-X (tested with 10.7 Lion).

Pyglet 1.1 uses the Carbon framework, but this is not compatible with 64-bit Python installs. The Pyglet 1.2 branch has been modified to use Quartz, but no releases of this branch have seen the light of day (sigh). We must instead install Pyglet from the Mercurial repository.

The Quartz bindings require the use of PyObjc but the latest versions do not work with Pip. The patches to PyObjc’s that I’ve seen on the internet do not work for me. The following is the only method I’ve had work.

Remove any existing Pyglet install

pip uninstall pyglet

Install Pyglet from the repository

pip install hg+

We need to install PyObjc for the new Pyglet Quartz API. But PyObjc is horribly broken and the latest version does not install with Pip or easy_install.

We must instead install an older version.

pip install pyobjc==2.2

You should now have a working Pyglet installation.

About these ads

11 Responses to “Installing Pyglet in Mac OS X”

  1. Winston Says:

    Thank you for posting this. I’ve been trying to get Pyglet to run on Lion and having a terrible time.

  2. Worked like a charm. Thanks for posting this.

  3. what is pip i keep getting an error that is is an unknown command

  4. Hi, I’m struggling to make “pip install pyobjc==2.2″ but keep on getting some compiler error which is mentioned at “″.

    I found some solution like have “arch -i386 python” command to force the python run in 32 bit mode, which seems to work alright now.

    BTW, the pyglet 1.2alpha has supported python 64 bit system. I’ve tried it, but there is some weird problem, so I don’t keep on figuring.

    • You shouldn’t need PyObjC for the latest versions of Pyglet.
      Try installing directly from pip (pip install pyglet).
      If not, try installing, via Mercurial, directly from their repository (pip install hg+

      Let me know how that goes =)


  5. MacMonk Says:

    After downloading the .tar file and installation i had the same problem….

    solved by terminal:
    defaults write Prefer-32-Bit -bool yes

    works now like a charm!

  6. James Says:

    Thank you so much!

  7. Fabian Mueller Says:

    Thanks a lot!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 119 other followers

%d bloggers like this: