[CentralOH] Python bit size

Mark Erbaugh mark at microenh.com
Tue May 10 21:23:28 CEST 2011

On May 10, 2011, at 2:00 PM, m g wrote:

>>>> import platform
>>>> platform.architecture()
> ('32bit', 'ELF')
> On Tue, May 10, 2011 at 1:29 PM, Mark Erbaugh <mark at microenh.com> wrote:
>> Is there a way to determine whether python is running in 32-bit or 64-bit mode?


Thanks for the reply, but this doesn't appear to work on a Mac with Snow Leopard.  Apparently, the default Python that comes with SL is a universal binary containing both 32 and 64 bit versions.  By using the arch command or setting an environment variable (VERSIONER_PYTHON_PREFER_32_BIT), you can force Python to load either as 32 or 64 bit.  I know that I'm getting different versions because sys.maxint returns different values (2147483647 for 32-bit and 9223372036854775807 for 64-bit), but on my Mac platform.architecture() always returns ('64bit', ''). I think it's telling me that the OS is 64-bit.

This is important to me because the default version of wxPython that comes with Snow Leopard only supports 32-bit. If you do an import wx with 64-bit python, you get a nice error message. If you do it with 32-bit python, it works fine.  FWIW, wxPython now supports 64-bit python but pre-built installs are only available for Python 2.7 and later, the default Python on Snow Leopard is 2.6.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20110510/d57ab5be/attachment.html>

More information about the CentralOH mailing list