Python: What OS am I running on?

Mark Harrison picture Mark Harrison · Aug 5, 2008 · Viewed 316.3k times · Source

What do I need to look at to see whether I'm on Windows or Unix, etc?

Answer

Louis Brandy picture Louis Brandy · Aug 5, 2008
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'

The output of platform.system() is as follows:

  • Linux: Linux
  • Mac: Darwin
  • Windows: Windows

See: platform — Access to underlying platform’s identifying data