0

I think I have downloaded pygame wrong. Whenever I try to import and initialize it I always get this error:

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

Can someone explain what this is?

Ted Klein Bergman
  • 9,146
  • 4
  • 29
  • 50
  • 1
    There is this http://stackoverflow.com/questions/7775948/no-matching-architecture-in-universal-wrapper-when-importing-pygame – Paul Rooney Feb 19 '17 at 22:53
  • Possible duplicate of ["no matching architecture in universal wrapper" when importing pygame](http://stackoverflow.com/questions/7775948/no-matching-architecture-in-universal-wrapper-when-importing-pygame) – 657784512 Feb 19 '17 at 22:57
  • True, but those answers are quite a bit out of date (2011 & 2013). The preferred install method for pygame is now to use the PyPI version. – Chris Feb 19 '17 at 23:00

1 Answers1

1

It looks like you are trying to install Pygame against the OS X included version of Python. This is a bad idea for several reasons:

  1. It's old - the version that ships with OS X is an older 2.7 release.
  2. It's non-standard - Apple has modified it in un-obvious ways.
  3. You can't mess with it - you can break your OS X installation if you tinker with it.

For this reason, it is highly recommended that you set up a development environment with a separate, fresh install of Python. The easiest way to do this is with Homebrew, although you can download the installer from http://python.org as well.

While you're at it, I strongly recommend you use Python 3 (the current version is 3.6). There is no reason for a beginner to be using 2.7.

Once you have Python installed correctly, installing Pygame is as simple as:

$ pip3 install pygame
Chris
  • 898
  • 1
  • 5
  • 8