简体   繁体   English

如何在安装了python 2.7的Mac上安装pygame?

[英]How to install pygame on Mac with python 2.7 installed?

I want to install pygame on Mac 10.6.8. 我想在Mac 10.6.8上安装pygame。
I managed to install python 2.7.9 and to make it stable. 我设法安装python 2.7.9并使其稳定。
I tried to install different versions of pygame but none worked: for example with the 1.9.1 it gives me this error: 我试图安装不同版本的pygame但没有一个工作:例如使用1.9.1它给了我这个错误:

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. 我不知道它是否是计算机体系结构(32/64位)的问题,或者因为python和pygame的版本不匹配。

I tried to look further in the official site of pygame but did not solve a thing. 我试图在pygame的官方网站上进一步查看,但没有解决问题。

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. 请注意,我已经在stackoverflow上查看了其他类似的问题。

Seems there are some binary incompatible issue. 似乎存在一些二进制不兼容的问题。 Maybe you can download the source and compile it: https://bitbucket.org/pygame/pygame 也许你可以下载源代码并编译它: https//bitbucket.org/pygame/pygame

The solution for me, after a lot of searching, is described in this link , using homwbrew and pip. 经过大量搜索后,我的解决方案在此链接中使用homwbrew和pip进行了描述。

  • install XQuarts if not already installed from the site 如果尚未从站点安装XQuarts,请安装
  • install homebrew ( link here ) 安装homebrew( 链接在这里
  • install python3 with the command brew install python3 in the terminal 在终端中使用命令brew install python3
  • install the Mercurial version control system: brew install mercurial 安装Mercurial版本控制系统: brew install mercurial
  • do the same for the git version control system, which is needed by a dependency package: brew install git 为git版本控制系统做同样的事情,这是依赖包所需要的: brew install git
  • Now install all the dependencies of Pygame: brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi 现在安装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 ) 安装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 /usr/local/share/python3/pip install hg + http://bitbucket.org/pygame/pygame

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM