【问题标题】:Can't install pygame on mac无法在 mac 上安装 pygame
【发布时间】:2017-06-19 21:44:31
【问题描述】:

我正在尝试在我的 Mac 上安装 pygame,当我导入 pygame 时,返回以下错误

Traceback (most recent call last):   File "<pyshell#0>", 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 位 python。

提前致谢

【问题讨论】:

    标签: python macos python-2.7 pygame


    【解决方案1】:

    编辑:我意识到这些步骤最初是为 python3 设计的。它应该仍然适用于 python2,但我无法确认,这只是我拥有的最佳答案。

    假设您使用的是最新的 macOS,以下是我用来安装 pygame 的步骤。尝试卸载您之前为 pygame 安装的内容,我不确定这会如何影响它。这还将安装 IDLE 程序,一个由 py​​thon 开发的 python IDE,如果你还没有的话。

    如果您使用的是旧版 mac,请点击底部的源链接,我们提供旧版 mac 的说明,这将涉及下载 xcode 等程序。

    1. 安装自制软件。进入终端并粘贴

      ruby -e "$(curl -fsSL https&lt;nolink&gt;://raw.githubusercontent.com/Homebrew/install/master/install)"

      然后回车。

    2. 将以下内容粘贴到终端,在每一行后按回车:

      brew install python(python3 用户为brew install python3

      brew install mercurial

      brew install sdl sdl_image sdl_mixer sdl_ttf portmidi

      brew tap homebrew/headonly(如果您在这里遇到任何问题,请改用brew install --HEAD smpeg

      brew install smpeg

      sudo -H pip install hg+http&lt;nolink&gt;://bitbucket.org/pygame/pygame(您必须输入密码,并且您必须是管理员。Python3 用户应使用sudo -H pip3 install hg+http&lt;nolink&gt;://bitbucket.org/pygame/pygame

    Source (although some info was updated)

    【讨论】:

    【解决方案2】:

    实际上,对我来说,在 03/2020 使用最新的操作系统 / Python 等。我使用了所有命令,除了最后一个不起作用的命令。我只需运行它并成功(!):

    pip3 install pygame
    

    【讨论】:

    • 谢谢!这里也一样!
    【解决方案3】:

    假设您已经安装了 Python,我必须使用这些说明才能使其在 2020 年 6 月 2 日在带有 Python 3.8 的 MAC OS 10.14.4 上运行。

    brew install mercurial
    brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
    brew install smpeg
    pip install https://github.com/pygame/pygame/archive/1.9.4.zip
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-14
      • 1970-01-01
      • 1970-01-01
      • 2015-04-02
      相关资源
      最近更新 更多