HiveBrain v1.2.0
Get Started
← Back to all entries
snippetpythonCritical

How to identify which OS Python is running on

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
howpythonidentifyrunningwhich

Problem

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

Solution

>>> 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

Code Snippets

>>> import os

>>> os.name
'posix'

>>> import platform

>>> platform.system()
'Linux'

>>> platform.release()
'2.6.22-15-generic'

Context

Stack Overflow Q#1854, score: 1332

Revisions (0)

No revisions yet.