1

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)

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the solution, Ned! It helped me get LilyPond's mid2ly script working (it was using a 32 bit midi.so). I changed the shebang line to #!/usr/bin/env /usr/bin/arch -i386 python and that solved the problem.
0

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.

2 Comments

Weird, any reason why /usr/bin/python would not be able to run in 32-bit mode though?
It can, you just can't do it via the arch command. Arch runs /usr/bin/python with the i386 arch and then it in turn does its own thing when it runs python2.6. As mentioned above there are other ways to tell /usr/bin/python which architecture of python2.6 should be executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.