How do I force Python to be 32-bit on Snow Leopard and other 32-bit/64-bit questions How do I force Python to be 32-bit on Snow Leopard and other 32-bit/64-bit questions python python

How do I force Python to be 32-bit on Snow Leopard and other 32-bit/64-bit questions


  1. You can find out a lot about the Python version you're running via the platform module (the sys module also has a few simple helpers)

  2. On Mac OS X, you can run a "fat binary" with your chosen architecture with, for example,

    arch -i386 /usr/bin/python

I do not recommend altering /usr/lib/python itself (with the lipo command) -- you could easily make your system unusable by tampering with system files. Maybe installing a separate Python from python.org (for application purposes) while leaving the system Python alone is an acceptable strategy to you -- it's definitely safer than altering system files!-)

As for your third question, hmmm, this one's a stumper to me -- and definitely a question for superuser.com (as well as completely unrelated to Python, it also seems completely unrelated to programming;-).


Fix for use with virtualenv on Snow Leopard

danielrsmith's answer works for me when I am not using virtualenv, but virtualenv makes a copy of the python executable which causes it not to work:

$ which python/Users/cogg/.virtualenvs/tweakeats/bin/python$ python[...]>>> import sys>>> sys.maxint9223372036854775807

because this is a copy of python, I used lipo on it to remove the 64-bit architecture. This allows me to use 32-bit python 2.6 with virtualenv:

$ lipo -info /Users/cogg/.virtualenvs/tweakeats/bin/pythonArchitectures in the fat file: /Users/cogg/.virtualenvs/tweakeats/bin/python are: x86_64 i386 ppc7400$ mv /Users/cogg/.virtualenvs/tweakeats/bin/python /Users/cogg/.virtualenvs/tweakeats/bin/python.old$ lipo -remove x86_64 /Users/cogg/.virtualenvs/tweakeats/bin/python.old -output /Users/cogg/.virtualenvs/tweakeats/bin/python$ python[...]>>> import sys>>> sys.maxint2147483647