Possible values from sys.platform?

PythonCross Platform

Python Problem Overview


What are the possible return values from the following command?

import sys
print sys.platform

I know there is a lot of possibilities, so I'm mainly interested in the "main" ones (Windows, Linux, Mac OS)

Python Solutions


Solution 1 - Python

┍━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━┑
│ System              │ Value               │
┝━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━┥
│ Linux               │ linux or linux2 (*) │
│ Windows             │ win32               │
│ Windows/Cygwin      │ cygwin              │
│ Windows/MSYS2       │ msys                │
│ Mac OS X            │ darwin              │
│ OS/2                │ os2                 │
│ OS/2 EMX            │ os2emx              │
│ RiscOS              │ riscos              │
│ AtheOS              │ atheos              │
│ FreeBSD 7           │ freebsd7            │
│ FreeBSD 8           │ freebsd8            │
│ FreeBSD N           │ freebsdN            │
│ OpenBSD 6           │ openbsd6            │
┕━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━┙

(*) Prior to Python 3.3, the value for any Linux version is always linux2; after, it is linux.

Solution 2 - Python

Mac OS X (10.4, 10.5, 10.7, 10.8):

darwin

Linux (2.6 kernel):

linux2

Windows XP 32 bit:

win32

Versions in brackets have been checked - other/newer versions are likely to be the same.

Solution 3 - Python

> As others have indicated, sys.platform > is derived from the name that the > system vendor gives their system. > However, Python also adds > plat- to sys.path, so > you can look at all the plat-* > directories in the Python > distribution. > > This gives you the list > > aix3 aix4 atheos beos5 darwin freebsd2 > freebsd3 freebsd4 freebsd5 freebsd6 > freebsd7 generic irix5 irix6 linux2 > mac netbsd1 next3 os2emx riscos sunos5 > unixware7 > > Of course, sys.platform can have > additional values, when Python gets > compiled on a system for which no > platform-specific directory has been > created.

From here.

Solution 4 - Python

FreeBSD 7.0: freebsd7. FreeBSD8 but build performed on previous version, same answer.

So be aware you get the platform used for the build, not necessarely the one you're running on.

Solution 5 - Python

As of Dec 29 2013, OS X 10.9.1 Mavericks is still labeled Darwin.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondbrView Question on Stackoverflow
Solution 1 - PythonICBView Answer on Stackoverflow
Solution 2 - PythondbrView Answer on Stackoverflow
Solution 3 - PythonMitch WheatView Answer on Stackoverflow
Solution 4 - PythonKeltiaView Answer on Stackoverflow
Solution 5 - PythonJason ElwoodView Answer on Stackoverflow