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 setup.py 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+https://pyglet.googlecode.com/hg/
Edit: The following is no longer needed
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.
2012/03/04 at 3:54 pm
Thank you for posting this. I’ve been trying to get Pyglet to run on Lion and having a terrible time.
2012/03/04 at 5:14 pm
Me too =P
I actually gave up last time.
Glad to have helped =)
Cheers,
Adam
2012/03/09 at 5:03 am
Worked like a charm. Thanks for posting this.
2012/07/02 at 4:03 pm
Thank you!
2013/04/10 at 1:10 am
what is pip i keep getting an error that is is an unknown command
2013/07/19 at 4:03 pm
Pip is a package manager for Python ( https://en.wikipedia.org/wiki/Pip_(Python) ).
It’s meant as a replacement to the older alternative EasyInstall ( https://en.wikipedia.org/wiki/EasyInstall )
try running:
python easy_install pip
Depending on how you’ve setup Python, you may need to use sudo to gain administrator privileges.
sudo python easy_install pip
If neither of those work then you probably don’t have setuptools installed.
http://www.pip-installer.org/en/latest/installing.html
It should already be present if you’re running OS-X.
If you’re running on Windows, try the following:
http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows
2013/06/22 at 11:37 am
Hi, I’m struggling to make “pip install pyobjc==2.2” but keep on getting some compiler error which is mentioned at “http://trac.macports.org/ticket/35325”.
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.
2013/07/19 at 3:58 pm
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+https://code.google.com/p/pyglet/).
Let me know how that goes =)
Cheers,
Adam
2013/09/26 at 11:22 pm
After downloading the .tar file and installation i had the same problem….
solved by terminal:
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
works now like a charm!
2013/12/24 at 7:28 am
Thank you so much!
2013/12/30 at 2:03 am
Thanks a lot!
2014/05/15 at 11:13 pm
Thanks for posting this.
I followed all steps but still receive the error message you posted above:
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
I’m working on OSX 10.9.2 with 64-bit Python 2.7.6.
The command “import pyglet” works, but “import piglet.gl” fails. Do you have any idea?
2014/07/03 at 3:02 pm
I’m not sure. I’ve seen that before. I think it was to do with 64bit python trying to use 32bit libs. Not sure why that’s the case here.
Are you using the system python? Perhaps try a custom installation, I’ve had trouble with the default python previously and I don’t use it anymore.
I’ve updated the post to remove the part about ‘pyobjc’ being required. Perhaps remove it and try again?
2014/06/13 at 2:23 pm
These two steps worked for me:
sudo pip uninstall pyglet
sudo pip install hg+https://code.google.com/p/pyglet/
2014/07/03 at 3:02 pm
Thanks, this was an old post and I never got around to updating it. I’ve done so now.
Cheers
2015/10/15 at 3:22 pm
[…] Similar to above, installing my own did the trick best. I adapted the instructions I found on this site: https://twistedpairdevelopment.wordpress.com/2012/02/21/installing-pyglet-in-mac-os-x/ […]
2020/12/24 at 11:12 pm
[…] Similar to above, installing my own did the trick best. I adapted the instructions I found on this site: https://twistedpairdevelopment.wordpress.com/2012/02/21/installing-pyglet-in-mac-os-x/ […]
2023/03/22 at 3:06 am
dedicated mining server
Installing Pyglet in Mac OS X | Twisted Pair Development