为Mac OS X 10.6.8安装Pygame。

[英]Installing Pygame for Mac OS X 10.6.8


Using Python 2.7.2. When I try to import pygame I get this error message:

使用Python 2.7.2。当我试图导入pygame时,我得到了这个错误信息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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 not exactly sure what this means. Should I compile pygame myself?

我不太清楚这意味着什么。我应该自己编译pygame吗?

5 个解决方案

#1


32  

The Python 2.7.3 .dmg Mac OS installer installs both 64-bit and 32-bit binaries in:

Python 2.7.3 .dmg Mac OS安装程序安装了64位和32位二进制文件:

/Library/Frameworks/Python.framework/Versions/2.7/bin/

/图书馆/框架/ Python.framework /版本/ 2.7 / bin /

There is a 32-bit binary called python2.7-32 in that folder.

在该文件夹中有一个32位的二进制文件,名为python2.7-32。

To use it in the Terminal simply type $ python2.7-32 instead of python

要在终端中使用它,只需输入$ python2.7-32,而不是python。

To use it in IDLE simply rename the 64-bit python2.7 binary to something like python2.7-64 then rename python2.7-32' topython2.7` and next time you launch IDLE or the Terminal it will use the 32-bit binary. Change it back when you are done.

要在IDLE中使用它,只需将64位的python2.7二进制文件重命名为python2.7-64,然后重新命名python2.7-32' topython2.7 ',下次启动IDLE或终端时,它将使用32位二进制。当你做完的时候把它换回来。

You can also force launch IDLE in 32-bit mode from the Terminal:

你也可以从终端的32位模式中强制启动IDLE:

$ arch -i386 /Library/Frameworks/Python.framework/Versions/2.7/bin/idle2.7 -n

$ arch -i386 /库/框架/Python.framework/版本/2.7/bin/idle2.7 -n。

You can create a shell script Automator application to make it easier to launch.

您可以创建一个shell脚本自动程序,以使其更容易启动。

#2


3  

The clue is in the last line no matching architecture in universal wrapper. Most likely you are using precompiled 32-bit binaries on a 64-bit system.

线索是在最后一行没有匹配的架构在通用包装。很可能是在64位系统上使用预编译的32位二进制文件。

You can try reinstalling or compiling from scratch but it would probably be far easier to just force python to run in 32-bit. Lots more info over here in this post.

您可以尝试从头开始重新安装或编译,但是仅仅强迫python在32位中运行可能要容易得多。这里有更多的信息。

#3


0  

I was having the same problem. I had Python 2.7.2, the installation version for OSX 10.6. Here is what I did to fix it:

我也有同样的问题。我有Python 2.7.2, osx10.6的安装版本。下面是我所做的修复工作:

1) Deleted my current installation of Python, both from the applications folder and from /Library/Frameworks/Python.framework (I just deleted 2.7.2, left 3.2 alone)

1)删除了我当前安装的Python,无论是从应用程序文件夹还是从/库/框架/Python.framework(我刚刚删除了2.7.2,仅剩下3.2)

2) Reinstalled Python 2.7.2, the installation version for OSX 10.3 (my pygame installation file was labeled for OSX 10.3, which prompted me in this direction)

2)重新安装Python 2.7.2, osx10.3的安装版本(我的pygame安装文件被标记为osx10.3,提示我在这个方向)

3) Reinstalled pygame

3)重新安装pygame

Now pygame imports without throwing an error.

现在,pygame导入而不抛出错误。

#4


0  

If you don't want to mess with system file then the easiest way is reinstalling Python 2.7.2 but the 32-bit version only. Get it here.

如果您不想破坏系统文件,那么最简单的方法是重新安装Python 2.7.2,但是只需要32位版本。把它在这里。

The dmg that includes both 64/32 bits is causing this mess.

包括64/32位的dmg造成了这种混乱。

#5


0  

What I'd recomend is using a decent Python IDE, like PyCharm.

我想要的是使用一个像样的Python IDE,比如PyCharm。

I've installed both the 3.3(x64), 3.3(x86) and the 2.7.6 from python.org with both architectures included.

我已经在python.org上安装了3.3(x64)、3.3(x86)和2.7.6,其中包括两个架构。

All I have to do is to set up an interpreter configuration for each and I can pick and choose on a project by project level.

我所要做的就是为每个人设置一个解释器配置,我可以根据项目级别来选择和选择一个项目。

For me this is the definite way of smooth Python Development, contra Python Mangling and manual workarounds.

对我来说,这是平滑Python开发的明确方式,与Python的管理和手工解决方案相一致。

The Community Version of the PyCharm IDE is even free as in beer! Go get it over at JetBrains Site

社区版的PyCharm IDE甚至是免费的啤酒!到JetBrains网站去买。

It's a breeze to use and behaves the same across both Windows, Linux and OS X. It also acts as a package manager, so you can install different components straight from the IDE and run Console sessions using different configurations. It also lets you set up virtualenv's easily.

在Windows、Linux和OS x上使用和操作都是一样的,它也是一个包管理器,所以您可以直接从IDE安装不同的组件,并使用不同的配置运行控制台会话。它还可以轻松设置virtualenv。

Enough propaganda! Go try it out yourself instead.

足够的宣传!你自己去试试吧。

And yes, I got PyGame working using this approach...

是的,我用这种方法得到了PyGame…

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2011/11/26/4cb08bdd6fa21420ff0c5a470674b287.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告