简体   繁体   中英

Running python in 32-bit more for wxPython

I am trying to run python in 32 bit mode on Mac OS X Snow Leopard, and I have been having some success, but with the following weirdness.

If I run it with /usr/bin/python, it seems to not want to run in 32 bit mode, but if I run it using /usr/bin/python2.6, it runs in 32 bit mode fine. As far as I could tell before this point /usr/bin/python was the same as /usr/bin/python2.6. Does anyone know why they would behave differently here?

zrbecker:src$ /usr/bin/python --version
Python 2.6.1
zrbecker:src$ /usr/bin/python2.6 --version
Python 2.6.1
zrbecker:src$ arch -i386 /usr/bin/python2.6 -c 'import wx'
zrbecker:src$ arch -i386 /usr/bin/python -c 'import wx'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/var/tmp/wxWidgets/wxWidgets-13~231/2.6/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/__init__.py", line 45, in <module>
  File "/var/tmp/wxWidgets/wxWidgets-13~231/2.6/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/_core.py", line 4, in <module>
ImportError: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/_core_.so: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)

In OS X 10.6, Apple provided a way to permanently select whether the Python 2.6 supplied in OS X runs in 64-bit mode or 32-bit mode ( VERSIONER_PYTHON_PREFER_32_BIT ) and other options. See man 1 python for details. The /usr/bin/python program is a front-end to that and examines the selected options, set either by default plists or by environment variables, and spawn the desired interpreter version in the selected mode, regardless of the mode that the wrapper program is launched in (via arch for instance). /usr/bin/python2.6 is a slightly modified version of the standard OS X pythonw program and it launches the interpreter in the mode it itself is launched in. The standard python.org distribution for 2.6 does not have similar code. In newer versions of Python, 2.7 and 3.2, the pythonw executable also honors the mode it is launched in, so arch -i386 will work.

By the way, Apple makes available here the source of various open source products, including Python, incorporated into OS X releases along with the customizations patches used to build it.

Do:

file /usr/bin/python /usr/bin/python2.6
ls -l /usr/bin/python /usr/bin/python2.6

You should find they're different executables, not just symlinks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM