如何在安装了python 2.7的Mac上安装pygame?
问题内容:
我想在Mac 10.6.8上安装pygame。
我设法安装python 2.7.9并使其稳定。
我尝试安装不同版本的pygame,但是没有用:例如在1.9.1中,它会给我这个错误:
输出:
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
我不知道这是不是计算机体系结构问题(32/64位),还是因为python和pygame的版本不匹配。
我试图在pygame的官方网站上进一步查找,但没有解决任何问题。
有人有同样的问题吗?怎么解决呢?
请注意,我已经看过关于stackoverflow的其他类似问题。
问题答案:
经过大量搜索之后,此链接中使用homwbrew和pip为我介绍了解决方案。
- 如果尚未从站点安装XQuarts,请安装
- 安装自制程序(链接在这里)
brew install python3
在终端中使用命令安装python3- 安装Mercurial版本控制系统:
brew install mercurial
- 对git版本控制系统执行相同的操作,这是依赖包所需的:
brew install git
- 现在安装Pygame的所有依赖项:
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
pip
使用命令安装/usr/local/share/python3/easy_install pip
(在我的情况下,文件夹为/usr/local/Cellar/python3/3.4.3_2/bin
)/usr/local/share/python3/pip install hg
+ http://bitbucket.org/pygame/pygame