Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

python - Installing Pygame for Mac OS X 10.6.8

Using Python 2.7.2. When I try to import pygame I get this error message:

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'm not exactly sure what this means. Should I compile pygame myself?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Python 2.7.3 .dmg Mac OS installer installs both 64-bit and 32-bit binaries in:

/Library/Frameworks/Python.framework/Versions/2.7/bin/

There is a 32-bit binary called python2.7-32 in that folder.

To use it in the Terminal simply type $ python2.7-32 instead of python

To use it in IDLE simply rename the 64-bit python2.7 binary to something like python2.7-64 then rename python2.7-32' topython2.7` and next time you launch IDLE or the Terminal it will use the 32-bit binary. Change it back when you are done.

You can also force launch IDLE in 32-bit mode from the Terminal:

$ arch -i386 /Library/Frameworks/Python.framework/Versions/2.7/bin/idle2.7 -n

You can create a shell script Automator application to make it easier to launch.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...