r0w
r0w

Reputation: 165

Why is python giving the wrong windows version?

I want a program to determine which OS and its version is running on the computer. I was really confused when platform.release() returned '8' since my computer was originally running on windows 8 but I updated on windows 10 several months ago.

My guess would be that it is more of a windows issue than a python problem. Is there a way o fix this? Or should I use a different module than platform?

I am using python 3.4.3. The whole version name platform.platform() returns is 'Windows-8-6.2.9200' but I can't tell whether it is the very first version on the computer or the last one before the Update.

Upvotes: 3

Views: 1046

Answers (3)

ddbug
ddbug

Reputation: 1539

Windows 10 is notorious exactly for this issue, hardship of detecting the true Windows version via previously known API. To make the long story short (sorry if this doesn't sound like a 'quality' answer) one needs either a OS compatibility element in the app manifest, or egregious hacks. Previously known API (GetVersionEx, VerifyVersionInfo) declared deprecated. So, what the Python interpreter gets, depends likely on whether it is built with a suitable manifest.

Recent Python executables have Win10 listed in the manifest (yes, I've checked, on v. 3.6.1) so they can get the correct Win10 version in a normal way... Until Microsoft breaks it again.

Upvotes: -1

robert_x44
robert_x44

Reputation: 9314

From the Python Changelog Documentation for 3.4.4-release-candidate-1

bpo-19143: platform module now reads Windows version from kernel32.dll to avoid compatibility shims.

which fixes the referenced bug:

Python is returning incorrect version info under Windows 8.1. ... it appears MS is "deprecating" GetVersionEx()

which references a StackOverflow question.

Upvotes: 3

El-Chief
El-Chief

Reputation: 384

import platform
platform.platform()

That gives me the number 10, I assume since I'm running windows 10.

platform.system()

That returns windows.

Upvotes: 0

Related Questions