I have installed pygames on my mac, using the installer in the following package found on the pygame.org site: pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg.
I have installed python with the Python 2.7.2 Mac OS X 64-bit/32-bit x86-64/i386 Installer found on python.org, and ran easy_install pyobjc
so that I now have pyobjc 2.2 installed.
But when I try the to import pygame in the repl, I get this:
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py", line 95, in <module>
from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper
I admit this is a guess, but could this be a 32 vs. 64 bit issue?
If I do:
file /usr/bin/python
I get:
python: Mach-O universal binary with 2 architectures
python (for architecture x86_64): Mach-O 64-bit executable x86_64
python (for architecture i386): Mach-O executable i386
Wondering what you see on your add-in file?
For example, if it's 32 bit, then run Python that mode:
arch -i386 /usr/bin/python
If that's not exactly it, at least this will hopefully get you in the right direction.
This was a 32 bit vs 64 bit issue for me. I followed the directions listed here: http://web.mit.edu/6.090/www/pygame.html and the issue was resolved.
来源:https://stackoverflow.com/questions/9088051/unable-to-import-pygame