11

I'm on a MacBook Pro running Snow Leopard 10.6.8 and Python 2.7.2. I went on the pygame website, downloaded and installed all the required frameworks and programs, compiled and installed pygame, but I cant import the module into python. I downloaded an example program off of the pygame website and every time I run it I get this error:

Traceback (most recent call last):
File "/Users/jesse/Downloads/PurpleMines/PurpleMines.py", line 3, in <module>
from pygame import *
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 guessing its a problem having to do with running a 64-bit OS?

Thanks in advance for the help.

SnowBeef
  • 143
  • 1
  • 2
  • 10
  • What does the command `file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so` report? – Gordon Davisson Oct 15 '11 at 21:18
  • `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: Mach-O universal binary with 2 architectures /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so (for architecture ppc): Mach-O bundle ppc /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so (for architecture i386): Mach-O bundle i386` – SnowBeef Oct 17 '11 at 05:18
  • It looks like you have an old version -- please edit the question to include details of which version you installed, which parts you compiled yourself, etc. – Gordon Davisson Oct 17 '11 at 05:32
  • I'm having the same error, and get the same values from file. My versions are Python 2.7.2 and Pygame 1.9.1. Both are the newest versions available (not counting Python 3.X). – Opieus Nov 20 '11 at 22:56

2 Answers2

14

Removing the old pygame install and reinstalling did the trick for me. I'm running Mac OS 10.7

sudo rm -Rf /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame

Then copy and install pygame from:

http://www.pygame.org/ftp/pygame-1.9.2pre-py2.7-macosx10.7.mpkg.zip

Sylvain
  • 1,193
  • 11
  • 14
  • 1
    I've been dealing with pygame dependency hell for hours -- this solved it right away. Thanks! – Christian Ternus Oct 08 '13 at 18:51
  • it does work, however: i DELETED the entire Python.framework folder and did the steps , it did not work, so do'n't do that! just delete the exact folder: site-packages - nothing more! – ERJAN Dec 14 '15 at 10:46
4

While what Sylvain said above is correct, this error is often caused by differences in bit rate between python and pygame. It is possible that redownloading it only helps because you get the correct distribution that time. To tell the bit rate of python, do this:

import platform
platform.architecture()

If it is 32 bit, get a 32 bit distribution of pygame. Otherwise, get a 64 bit distribution.

trevorKirkby
  • 1,886
  • 20
  • 47