Question

How do I figure out which Python architecture is provided in the preinstalled version of Lion OS 10.7?

I know you can't link 32 to 64 bit code, so I just don't want to mess it up by installing packages with different architectures.

My current version of Python is the 2.7.1

Was it helpful?

Solution

Use platform.architecture():

>>> import platform
>>> platform.architecture()
('64bit', '')

Run on my Mac OS X 10.8.4. Note that your Python executable may be a universal binary, in which case you could get the wrong architecture quoted:

Note: On Mac OS X (and perhaps other platforms), executable files may be universal files containing multiple architectures.

You can also test sys.maxsize:

>>> sys.maxsize > 2**32
True

The above would return False if you were running a 32-bit platform.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top