Possible values ​​from sys.platform?

What are the possible return values ​​from the following command?

import sys print sys.platform 

I know that there are many possibilities, so I am mainly interested in the "core" (Windows, Linux, Mac OS).

+66
python cross-platform
Jan 15 '09 at 10:02
source share
5 answers

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

 darwin 

Linux (kernel 2.6):

 linux2 

Windows XP 32 bit:

 win32 

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

+29
Jan 15 '09 at 10:03
source share
 ┍━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━┑ β”‚ 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 version of Linux was always linux2 ; after that is linux .

+79
Dec 14
source share

As others have pointed out, sys.platform comes from the name that the System Provider gives its system to. However, Python also adds plat- to sys.path, so you can look at all the plat- * directories in the Python distribution.

It gives you a 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 may have additional meanings when Python gets compiled on a system for which no directory for a particular platform has been created.

From here .

+22
Jan 15 '09 at 10:04
source share

FreeBSD 7.0: freebsd7 . FreeBSD8, but the build was done in the previous version, the same answer.

Know that you are getting the platform used to build, not just the one you are working on.

+7
Jan 15 '09 at 10:06
source share

As of December 29, 2013, OS X 10.9.1 Mavericks is still tagged with Darwin.

+2
Dec 29 '13 at 16:13
source share



All Articles