[英]PyGame Installation Mac OS X
I downloaded Python 2.7.10 and I wanted to install pygame.我下载了 Python 2.7.10,我想安装 pygame。 I downloaded the DMG from pygame's website (Version 1.9.1) and installed it.我从 pygame 的网站(版本 1.9.1)下载了 DMG 并安装了它。 To test if pygame was installed properly, I opened IDLE and entered the command import pygame
just for the following error to return:为了测试 pygame 是否安装正确,我打开 IDLE 并输入命令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'm running OSX Yosemite version 10.10.3, does anyone know how to fix this issue and properly install pygame without any issues>我正在运行 OSX Yosemite 版本 10.10.3,有谁知道如何解决这个问题并正确安装 pygame 没有任何问题>
How to install PyGame on the Mac OS X El Capitan 10.11.1如何在 Mac OS X El Capitan 10.11.1 上安装 PyGame
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.运行 brew 后,需要遵循一些特定说明。
You will also need to create a sitecustomize.py file in /Users/toasteez/anaconda/envs/pygame/lib/python2.7/site-packages您还需要在 /Users/toasteez/anaconda/envs/pygame/lib/python2.7/site-packages 中创建一个 sitecustomize.py 文件
I added the env to my Pycharm Project Interpreter and it seems fine.我将 env 添加到我的 Pycharm 项目解释器中,看起来不错。
This is the best method I've found for installing on OS X (and works with Python 3):这是我找到的在 OS X 上安装的最佳方法(并且适用于 Python 3):
Step 1: Install XCode command line tools第 1 步:安装 XCode 命令行工具
XCode is the tool from Apple for creating Mac and iOS applications. XCode 是来自 Apple 的用于创建 Mac 和 iOS 应用程序的工具。 It can be installed from the App Store (it's free).它可以从 App Store 安装(免费)。 When it's finished, type the following at the command line:完成后,在命令行中键入以下内容:
$ xcode-select --install
Step 2: Install Homebrew ( http://brew.sh )第 2 步:安装 Homebrew ( http://brew.sh )
Homebrew is a tool to easily install all kinds of software from the command line. Homebrew 是一个可以从命令行轻松安装各种软件的工具。 It saves you having to go to a bunch of different sites and download lots of individual installers.它使您不必去一堆不同的站点并下载许多单独的安装程序。 Copy and paste this on the command line:将其复制并粘贴到命令行上:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
and follow the directions.并按照说明进行操作。 You'll also need to install Homebrew Cask ( http://caskroom.io ):您还需要安装 Homebrew Cask ( http://caskroom.io ):
$ brew install caskroom/cask/brew-cask
Step 3: Install the rest of the software第 3 步:安装其余软件
Now we can start installing all the requirements for Pygame.现在我们可以开始安装 Pygame 的所有要求。 Just type the following commands one at a time and let the computer do its thing:只需一次输入以下命令,让计算机做它的事情:
$ brew cask install xquartz
$ brew install python3
$ brew install python
$ brew linkapps python3
$ brew linkapps python
$ brew install git
$ brew install sdl sdl_image sdl_ttf portmidi libogg libvorbis
$ brew install sdl_mixer --with-libvorbis
$ brew tap homebrew/headonly
$ brew install smpeg
$ brew install mercurial
$ pip3 install hg+http://bitbucket.org/pygame/pygame
Step 4: See if it works!第4步:看看它是否有效!
Now we can see if it works.现在我们可以看看它是否有效。 Run Python from the command line:从命令行运行 Python:
$ python3
and try loading Pygame:并尝试加载 Pygame:
>>> import pygame
If you don't see an error message, you're all set!如果您没有看到错误消息,那么您就大功告成了!
You should be able to use on Mac:您应该可以在 Mac 上使用:
pip3 install pygame
or on other computers:或在其他计算机上:
pip install pygame
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.