I think the platform module is really the best way to get this information.
>>> import platform >>> platform.platform() 'Windows-7-6.1.7601-SP1' platform.processor() 'Intel64 Family 6 Model 42 Stepping 7, GenuineIntel'
I donโt see where to get the hard answer to 32-bit windows from here, so I suggest the following:
try: os.environ["PROGRAMFILES(X86)"] bits = 64 except: bits = 32 print "Win{0}".format(bits)
or, if you need to know what flavor of Python you are using (since you can run x32 python under x64 Windows):
x32 python x64 windows: >>> platform.architecture() ('32bit', 'WindowsPE') >>> sys.version '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' x64 python x64 windows: >>> platform.architecture() ('64bit', 'WindowsPE') >>> sys.version '2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]'
Curtis Price
source share