【问题标题】:How to install pygame on Mac with python 2.7 installed?如何在安装了 python 2.7 的 Mac 上安装 pygame?
【发布时间】:2015-04-02 01:03:09
【问题描述】:

我想在 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 的其他类似问题。

【问题讨论】:

    标签: python macos pygame


    【解决方案1】:

    似乎存在一些二进制不兼容的问题。或许你可以下载源码编译一下:https://bitbucket.org/pygame/pygame

    【讨论】:

    • 我已经尝试过,我得到了这个错误:ld:在/Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks//smpeg.framework/smpeg,在架构文件中缺少所需的架构x86_64 x86_64 collect2:ld 返回 1 个退出状态 lipo:无法打开输入文件:/var/tmp//ccphUjIL.out(没有此类文件或目录)错误:命令“gcc-4.2”失败,退出状态为 1
    【解决方案2】:

    经过大量搜索,我的解决方案描述为 in this link,使用 homwbrew 和 pip。

    • 如果尚未从站点安装 XQuarts,请安装
    • 安装自制软件 (link here)
    • 在终端使用命令brew install python3安装python3
    • 安装 Mercurial 版本控制系统:brew install mercurial
    • 对依赖包需要的git版本控制系统做同样的事情:brew install git
    • 现在安装 Pygame 的所有依赖项:brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
    • 使用命令/usr/local/share/python3/easy_install pip 安装pip(在我的情况下,文件夹是/usr/local/Cellar/python3/3.4.3_2/bin
    • /usr/local/share/python3/pip install hg+http://bitbucket.org/pygame/pygame
    猜你喜欢
    • 1970-01-01
    • 2016-04-03
    • 2016-10-27
    • 2014-06-17
    • 1970-01-01
    • 2018-06-26
    • 2013-04-21
    • 1970-01-01
    • 2014-11-19
    相关资源
    最近更新 更多