python2.7安装pygame,如何在安装了python 2.7的Mac上安装pygame?

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

import pygame

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py", line 95, in

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.

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值