How to install pygame on Mac with python 2.7 installed?

那年仲夏 提交于 2019-12-19 09:22:30

问题


I want to install pygame on Mac 10.6.8.
I managed to install python 2.7.9 and to make it stable.
I tried to install different versions of pygame but none worked: for example with the 1.9.1 it gives me this error:

Output:

Traceback (most recent call last):
 File "/.../Desktop/example.py", 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

I don't know if it is a problem of computer architecture (32/64 bit) or because the versions of python and pygame do not match.

I tried to look further in the official site of pygame but did not solve a thing.

Did anyone have the same problem? How to solve it?

Please note that I have already taken a look at other similar questions on stackoverflow.


回答1:


Seems there are some binary incompatible issue. Maybe you can download the source and compile it: https://bitbucket.org/pygame/pygame




回答2:


The solution for me, after a lot of searching, is described in this link, using homwbrew and pip.

  • install XQuarts if not already installed from the site
  • install homebrew (link here)
  • install python3 with the command brew install python3 in the terminal
  • install the Mercurial version control system: brew install mercurial
  • do the same for the git version control system, which is needed by a dependency package: brew install git
  • Now install all the dependencies of Pygame: brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
  • install pip with the command /usr/local/share/python3/easy_install pip (in my case the folder was /usr/local/Cellar/python3/3.4.3_2/bin)
  • /usr/local/share/python3/pip install hg+http://bitbucket.org/pygame/pygame


来源:https://stackoverflow.com/questions/28288663/how-to-install-pygame-on-mac-with-python-2-7-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!