本文介绍了PyGame安装Mac OS X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了Python 2.7.10,并且想要安装pygame.我从pygame的网站(版本1.9.1)下载了DMG并进行了安装.为了测试pygame是否已正确安装,我打开IDLE并输入命令import pygame只是为了返回以下错误:

I downloaded Python 2.7.10 and I wanted to install pygame. I downloaded the DMG from pygame's website (Version 1.9.1) and installed it. To test if pygame was installed properly, I opened IDLE and entered the command import pygame just for the following error to return:

 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

我正在运行OSX Yosemite版本10.10.3,有谁知道如何解决此问题并正确安装pygame而没有任何问题>

I'm running OSX Yosemite version 10.10.3, does anyone know how to fix this issue and properly install pygame without any issues>

推荐答案

如何在Mac OS X El Capitan 10.11.1上安装PyGame

  1. 安装Anaconda 2.7
  2. 获取 SDL框架,运行dmg并将其复制到/Library/框架
  3. brew install sdl 请注意,您需要安装Homebrew
  4. 确保您具有XCODE和适用于XCODE的最新命令行工具
  5. 打开终端并运行

  1. Install Anaconda 2.7
  2. Get the SDL Framework run dmg and copy to /Library/Frameworks
  3. brew install sdl note you need Homebrew installed
  4. Ensure you have XCODE and latest Command Line Tools for XCODE
  5. Open Terminal and run

conda update conda

conda create -n py27 python

source activate py27

conda install binstar

conda install anaconda-client

conda install -c https://conda.binstar.org/erik pyobjc

conda install -c https://conda.binstar.org/erik pyobjc-core

conda install -c https://conda.binstar.org/erik pyobjc-framework-Cocoa

conda install -c https://conda.binstar.org/erik pyobjc-framework-Quartz

conda install numpy

conda install pyopengl

brew install homebrew/python/pygame

运行冲煮后,有一些特定的说明要遵循.

There are some specific instructions to follow after brew is run.

您还需要在/Users/toasteez/anaconda/envs/pygame/lib/python2.7/site-packages中创建一个sitecustomize.py文件

You will also need to create a sitecustomize.py file in /Users/toasteez/anaconda/envs/pygame/lib/python2.7/site-packages

我将环境添加到我的Pycharm项目解释器中,看起来不错.

I added the env to my Pycharm Project Interpreter and it seems fine.

这篇关于PyGame安装Mac OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:25