Scorpion_God
Scorpion_God

Reputation: 1499

Python pygame mac import

I installed pygame from pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg. I have Python 2.7.6 and OSX 10.9.2. For some reason, when I do the following I get an ImportError:

>>> import pygame

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import pygame
  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

How can I get pygame to work? And is there a way to get pygame for Python 3.4? I currently have both Python 2.7.6 and Python 3.4 installed.

Upvotes: 1

Views: 705

Answers (3)

Gaspump1112
Gaspump1112

Reputation: 113

To answer your second question, no, they only have pygame available for python 2.7. But for your first question, I don't know if this would work, but try using

import pygame
from pygame.locals import*
pygame.init()

That is what I need to initialize my pygame, so maybe it will work.

Upvotes: 0

Matthew Pace
Matthew Pace

Reputation: 155

You need to install a 32 bit version of Python. PyGame doesn't run on the 64 bit builds, and OSX ships with a 64 bit build.

When I was working with PyGame it was the sole reason I installed 32 bit Python. I wish they would work on 64 bit support more.

Upvotes: 1

soarjay
soarjay

Reputation: 651

Perhaps try using Macports to install pygame. That package that you installed was for version OSX 10.3 which used PowerPC architecture whereas you are running OSX 10.9 which uses Intel.

Upvotes: 1

Related Questions