0

I saw two relevant questions...

How to check if OS is Vista in Python?

Detect Windows 8.1 in Python?

The answer to the older question, 'platform.release()', appears to be unreliable between Windows Vista, 7, and 8 if I am understanding correctly. The second question has not been answered, and seemingly states that 'sys.getwindowsversion()' is also unreliable.

I do not have to worry about Windows versions older than XP or other OS's for this specific issue.

Community
  • 1
  • 1
womesiete
  • 341
  • 1
  • 4
  • 13

3 Answers3

1

Using platform is probably the most reliable

>>> import platform
>>> print platform.platform()
Windows-7-6.1.7601-SP1
>>>
Andy
  • 49,085
  • 60
  • 166
  • 233
  • I do not have access at the moment to a Windows 8 system to test this, but the other thread seemed to imply that the platform module was unreliable. It would be fantastic if it is not. Do you know what the output on a Windows 8 system would be? I only found error reports from searching. – womesiete Feb 01 '14 at 04:06
  • According to this bug report, it identifies Windows 8 correctly. http://bugs.python.org/issue16176 – Andy Feb 01 '14 at 13:43
  • Alas, Windows 10 returns 'Windows-8-6.2.9200', – nerdfever.com Mar 28 '18 at 19:00
0

simplicity in itself:

import platform
platform.platform()

Python platform library

0

Starting in Windows 8.1 Microsoft changed the way the underlying version functions work. So, while Windows 8.1 should return 6.3 as the version number it doesn't unless the application is specifically manifested for Windows 8.1. So, for Windows 8.1 and Server 2012 R2 platform.platform() won't work as expected. On my Windows 8.1 box I get this as the output:

>>> import platform
>>> platform.platform()
'Windows-post2008Server-6.2.9200'

The above shows Windows 8.1 clearly identified as NT version 6.2, which is wrong. It should have been 6.3.

See my answer on this other thread for a way to get the true Windows version number, even on Windows 8.1 and Server 2012 R2.

Community
  • 1
  • 1
Isaac
  • 215
  • 2
  • 8