2

我已经使用 MacPorts 将 pyglet 安装到 Mac OS X 10.7.4 上。

pyglet 仅在为 32 位拱门构建时才有效,因此为了使用它,我必须像这样从命令行运行 python,

arch -i386 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

然后我就可以成功运行pyglet“hello world”程序了。

但是,我喜欢在 Eclipse 中使用 PyDev,但我不知道如何配置 PyDev 以将 python 作为 32 位进程运行。

我添加了 MacPorts python,

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

作为 Python 解释器(Preferences > Pydev > Interpreter - Python)。我创建了一个新项目并将 MacPorts python 设置为项目的解释器。但是当我从这个项目中运行pyglet "hello world" 程序时,我收到以下错误

pydev debugger: starting
Traceback (most recent call last):
File "/Applications/eclipse/plugins/org.python.pydev.debug_1.6.2.2010090812/pysrc/pydevd.py", line 1145, in <module>
debugger.run(setup['file'], None, None)
File "/Applications/eclipse/plugins/org.python.pydev.debug_1.6.2.2010090812/pysrc/pydevd.py", line 916, in run
execfile(file, globals, locals) #execute the script
File "/Users/andrewfogg/Dropbox/EnvironmentalArt/src/art.py", line 2, in <module>
window = pyglet.window.Window()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/__init__.py", line 306, in __getattr__
__import__(import_name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/window/__init__.py", line 1669, in <module>
from pyglet.window.carbon import CarbonPlatform, CarbonWindow
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/window/carbon/__init__.py", line 69, in <module>
framework='/System/Library/Frameworks/QuickTime.framework')
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/lib.py", line 90, in load_library
return self.load_framework(kwargs['framework'])
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/lib.py", line 226, in load_framework
lib = ctypes.cdll.LoadLibrary(realpath)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/System/Library/Frameworks/QuickTime.framework/QuickTime, 6): no suitable image found.  Did find:
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture

这表明 PyDev 正在将 python 作为 64 位进程运行。

我可以看到我可以让我的 python 解释器设置环境变量(Preferences > Pydev > Interpreter - Python > Environment),但我不确定如何正确配置它(我已经尝试过)。

问题是:如何在 PyDev 中将 python 作为 32 位进程运行?

4

1 回答 1

2

我认为最好的方法是安装一个只有 32 位的 Python,而不是使用系统中安装的 Python。

或者如果你真的想使用系统中的那个,你可以看看:How do I force Python to be 32-bit on Snow Leopard 和其他 32-bit/64-bit questions on other ways to configure Python to以 32 位运行(VERSIONER_PYTHON_PREFER_32_BIT 环境变量似乎是一个不错的选择)。

于 2012-06-12T11:58:09.807 回答