[python-win32] How do I detect a 64 bit version of Windows?

Mark Hammond skippy.hammond at gmail.com
Sun Feb 19 23:57:39 CET 2012


On 19/02/2012 6:20 PM, Brian Curtin wrote:
> On Sat, Feb 18, 2012 at 21:11, Gelonida N<gelonida at gmail.com>  wrote:
>> On 02/18/2012 09:07 PM, Brian Curtin wrote:
>>> On Sat, Feb 18, 2012 at 13:22, Gremlin<gremlin at armarize.com>  wrote:
>>>
>>> import platform
>>> platform.machine()
>>>
>>> That will return "AMD64" on 64 bit. I don't have a 32-bit machine
>>> available but I believe it returns "x86".
>> This suggestion will not work for the OP.
>>
>> It will tell you the platform, for which python was compiled and not the
>> real platform of the machine you're running on.
>>
>> If you installed a 32 bit version of python on a 64 bit machine You will
>> get 'x86', which would be the wrong answer considering the OP's
>> requirements.
>
> This is false.
>
> platform.machine() is about the the computer itself - I fixed it in
> 2.6 to function properly, as it used to operate similar to
> platform.architecture() due to looking in the wrong place.
> platform.architecture() is about how Python was compiled.

Cool - that is good to know!  However, like gelonida, on 2.6 (and from a 
2 week old hg build which is reporting itself as 2.6.7+) I don't see the 
behaviour you suggest:

% py -2.6-32 -c "import platform, sys; print sys.version; print 
platform.machine()"

2.6.7+ (unknown, Feb 20 2012, 09:54:27) [MSC v.1500 32 bit (Intel)]
x86

but it does work as you describe in 3.3:

% py -3.3-32 -c "import platform, sys; print(sys.version); 
print(platform.machine())"

3.3.0a0 (default, Jan 28 2012, 15:39:56) [MSC v.1500 32 bit (Intel)]
AMD64

Mark


More information about the python-win32 mailing list