[LINUX] Plattform (OS) Beurteilung durch Python

Bei so vielen verfügbaren Betriebssystemen ist es ideal, ein Programm zu haben, das überall funktioniert. In Wirklichkeit müssen Sie jedoch möglicherweise ein betriebssystemabhängiges Programm schreiben.

In diesem Artikel haben wir Methoden zur Bestimmung von OS = Plattform gesammelt, um die Portabilität von Python zu verbessern.

Die Plattformen, die wir bestätigt haben (einschließlich Pläne zur Bestätigung), sind wie folgt.

  1. x86_64 (AMD64) -Serie 4. Linux (on Windows Hyper-V)
  2. System Debian 6. Ubuntu 6. Ubuntu 18.04 (Bionic Beaver)...(1) 7. Ubuntu 18.04 - Windows Subprocess for Linux...(2)
  3. Ubuntu 19.04 (Disco Dingo) ... (3) (nicht implementiert)
  4. Ubuntu 19.10 (Eoan Ermine) ... (4) (nicht implementiert) 8. Ubuntu 20.04 (Focal Fossa)...(5)
  5. System RedHat 9. CentOS 7. CentOS 6...(6) 8. CentOS 7...(7) 10. CentOS 8...(8) 7. alpine Linux(onUbuntudocker)...(9) 7. Windows 8. Windows 10 Home (with Native Python via Microsoft Store)...(10) 9. Windows 10 Pro (with Anaconda Python)...(11)
    1. UNIX 2. Solaris 2. Solaris 10(onVMwarePlayer)...(12) 3. Solaris 11(onVMwarePlayer)...(13) 4. FreeBSD...(14)
  6. ARM-System 8. Raspbian(buster)...(15) 9. Ubuntu 18.04(onRaspbiandocker)...(16) 10. CentOS 7(onRaspbiandocker)...(17) 11. alpine(onRaspbiandocker)...(18)

Zusammenfassung

Ziel benutzt
Python Ver.
sys.platform os.name platform.platform()[^1]
platform.platform(aliased)[^1]
(1) Ubuntu 18.04 3.6.8 linux posix Linux-4.15.0-88-generic-x86_64-with-Ubuntu-18.04-bionic

Das gleiche wie oben
(2) Ubuntu 18.04 - Windows Subprocess for Linux 3.6.9 linux posix Linux-4.4.0-18362-Microsoft-x86_64-with-Ubuntu-18.04-bionic

Das gleiche wie oben
(3) Ubuntu 19.04 Nicht implementiert
(4) Ubuntu 19.10 Nicht implementiert
(5) Ubuntu 20.04 3.8.2 linux posix Linux-5.4.0-29-generic-x86_64-with-glibc2.29

Das gleiche wie oben
(6) CentOS 6 3.6.8 linux posix Linux-2.6.32-754.el6.x86_64-x86_64-with-centos-6.10-Final

Das gleiche wie oben
(7) CentOS 7 3.6.8 linux posix Linux-3.10.0-1062.el7.x86_64-x86_64-with-centos-7.7.1908-Core

Das gleiche wie oben
(8) CentOS 8 Nicht implementiert
(9) alpine on Docker on Ubuntu 18.04 3.8.2 linux posix Linux-4.15.0-88-generic-x86_64-with

Das gleiche wie oben
(10) Windows Native Python 3.8.2 win32 nt Windows-10-10.0.18362-SP0

Das gleiche wie oben
(11) Windows Anaconda 3.7.6 win32 nt Windows-10-10.0.18362-SP0

Das gleiche wie oben
(12) Solaris 10 2.6.4 sunos5 posix SunOS-5.10-i86pc-i386-32bit-ELF

Solaris-2.10-i86pc-i386-32bit-ELF
(13) Solaris 11 2.7.9 sunos5 posix SunOS-5.11-i86pc-i386-32bit-ELF

Solaris-2.11-i86pc-i386-32bit-ELF
(14) FreeBSD 12.1 3.7.7 freebsd12 posix FreeBSD-12.1-RELEASE-amd64-64bit-ELF

Das gleiche wie oben
(15) Raspbian (buster) 3.7.3 linux posix Linux-4.19.97-v7+-armv7l-with-debian-10.3

Das gleiche wie oben
(16) Ubuntu 18.04 on Docker on Raspbian 3.6.9 linux posix Linux-4.19.97-v7+-armv7l-with-Ubuntu-18.04-bionic

Das gleiche wie oben
(17) CentOS 7 on Docker on Raspbian 3.6.8 linux posix Linux-4.19.97-v7+-armv7l-with-centos-7.6.1810-AltArch

Das gleiche wie oben
(18) alpine on Docker on Raspbian 3.8.2 linux posix Linux-4.19.97-v7+-armv7l-with

Das gleiche wie oben

[^ 1]: Beide terse = False

Python Platform Tips

Platform

sys.platform

sys.platform - sys ― System-specific parameters and functions ― Python 3.8.2 documentation

sys.platform

This string contains a platform identifier that can be used to append platform-specific components to sys.path, for instance.

For Unix systems, except on Linux and AIX, this is the lowercased OS name as returned by uname -s with the first part of the version as returned by uname -r appended, e.g. 'sunos5' or 'freebsd8', at the time when Python was built. Unless you want to test for a specific system version, it is therefore recommended to use the following idiom:

if sys.platform.startswith('freebsd'): # FreeBSD-specific code here... elif sys.platform.startswith('linux'): # Linux-specific code here... elif sys.platform.startswith('aix'): # AIX-specific code here...

For other systems, the values are:

System platform value
AIX 'aix'
Linux 'linux'
Windows 'win32'
Windows/Cygwin 'cygwin'
macOS 'darwin'

Python-Skript zur Überprüfung

tips.py


#!/usr/bin/env python
# -*- coding: utf-8 -*-

from six import print_

#def print_(*args):
#    for s in args:
#        print s,
#    print


import sys

print_("==================== sys.version ====================")
print_("sys.version:", sys.version)


print_("==================== sys.version_info ====================")
print_("sys.version_info:", sys.version_info)


print_("==================== sys.platform ====================")

sys_platform_str = sys.platform
print_("sys.platform:", sys_platform_str)
if sys_platform_str.startswith('sunos'):
    print_("{getstring}: Solaris/SunOS".format(getstring=sys_platform_str))
elif sys_platform_str.startswith('freebsd'):
    print_("{getstring}: FreeBSD".format(getstring=sys_platform_str))
elif sys_platform_str.startswith('aix'):
    print_("{getstring}: AIX".format(getstring=sys_platform_str))
elif sys_platform_str.startswith('linux2'):
    print_("{getstring}: docker/Windows Subsystem for Linux".format(getstring=sys_platform_str))
elif sys_platform_str.startswith('linux'):
    print_("{getstring}: Linux".format(getstring=sys_platform_str))
elif sys_platform_str.startswith('win32'):
    print_("{getstring}: Windows".format(getstring=sys_platform_str))
elif sys_platform_str.startswith('cygwin'):
    print_("{getstring}: Windows/Cygwin".format(getstring=sys_platform_str))
elif sys_platform_str.startswith('darwin'):
    print_("{getstring}: macOS".format(getstring=sys_platform_str))
else:
    print_("{getstring}: Unknown".format(getstring=sys_platform_str))


import os

print_("==================== os.name ====================")
os_name_str = os.name
if os_name_str.startswith('nt'):
    print_("{getstring}: Windows".format(getstring=os_name_str))
elif os_name_str.startswith('posix'):
    print_("{getstring}: macOS, Linux or UNIX".format(getstring=os_name_str))
else:
    print_("{getstring}: unknown".format(getstring=os_name_str))


try:
    os_uname = os.uname()
except Exception as e:
    pass
else:
    print_("==================== os.uname() ====================")
    print_("os.uname():", os_uname)
    print_("os.uname()[0:]:", os_uname[0:])

    sysname, nodename, release, version, machine = os.uname()
    print_('sysname: "{sysname}", nodename: "{nodename}", ' \
        'release: "{release}", version: "{version}", machine: "{machine}"' \
                  .format(sysname=sysname,
                          nodename=nodename,
                          release=release,
                          version=version,
                          machine=machine))

    uname = {}
    uname['sysname'], uname['nodename'], uname['release'], \
                      uname['version'], uname['machine'] = os.uname()
    print_('sysname: "{sysname}", nodename: "{nodename}", '
        'release: "{release}", version: "{version}", machine: "{machine}"' \
                  .format(sysname=uname['sysname'],
                          nodename=uname['nodename'],
                          release=uname['release'],
                          version=uname['version'],
                          machine=uname['machine']))


import platform

print_("==================== platform.platform() ====================")
print_("platform.platform(aliased=True, terse=False):",
        platform.platform(aliased=True, terse=False))
print_("platform.platform(aliased=True, terse=True):",
        platform.platform(aliased=True, terse=True))
print_("platform.platform(aliased=False, terse=False):",
        platform.platform(aliased=False, terse=False))
print_("platform.platform(aliased=False, terse=True):",
        platform.platform(aliased=False, terse=True))

platform_str = platform.platform(aliased=True, terse=True)
if platform_str.startswith('Windows-10'):
    print_("{getstring}: Windows 10".format(getstring=platform_str))
elif platform_str.startswith('Linux'):
    print_("{getstring}: Linux".format(getstring=platform_str))
elif platform_str.startswith('Solaris-2'):
    print_("{getstring}: Solaris".format(getstring=platform_str))
    if platform_str.startswith('Solaris-2.10'):
        print_("        Solaris 10")
    elif platform_str.startswith('Solaris-2.11'):
        print_("        Solaris 11")
    else:
        print_("        Solaris ??")
else:
    print_("{getstring}: Unknown".format(getstring=platform_str))


print_("==================== platform.*() ====================")
print_("platform.architecture():", platform.architecture())
print_("        sys.maxsize =", sys.maxsize)
print_("        sys.maxsize > 2**32 -->", sys.maxsize > 2**32)
print_("platform.machine():", platform.machine())
print_("platform.node():", platform.node())
print_("platform.processor():", platform.processor())
print_("platform.python_build():", platform.python_build())
print_("platform.python_compiler():", platform.python_compiler())
print_("platform.python_branch():", platform.python_branch())
print_("platform.python_implementation():", platform.python_implementation())
print_("platform.python_revision():", platform.python_revision())
print_("platform.python_version():", platform.python_version())
print_("platform.python_version_tuple():", platform.python_version_tuple())
print_("platform.release():", platform.release())
print_("platform.system():", platform.system())
print_("platform.system_alias():", platform.system_alias(platform.system(), platform.release(), platform.version()))
print_("platform.version():", platform.version())
print_("platform.uname():", platform.uname())
print_("platform.java_ver():", platform.java_ver())
print_("platform.win32_ver():", platform.win32_ver())

if sys.version_info[0:2] >= (3, 8):
    print_("platform.win32_edition():", platform.win32_edition())
if sys.version_info[0:2] >= (3, 8):
    print_("platform.win32_is_iot():", platform.win32_is_iot())

#print_("platform.popen():", platform.popen())
print_("platform.libc_ver():", platform.libc_ver())

if sys.version_info[0:2] >= (3, 8):
    print_("platform.mac_ver() - macOS version:", platform.mac_ver())
else:
    print_("platform.mac_ver() - darwin version:", platform.mac_ver())

#### Linux Distribution
if sys.platform.startswith('linux'):
    if sys.version_info[0:2] < (2, 6):      # not recomend over 2.6
        print_("platform.dist():", platform.dist())
        dist_name, dist_version, dist_id = platform.dist()
    elif sys.version_info[0:2] < (3, 5):    # not recomend over 3.5 and removed on 3.8

        print_("platform.linux_distribution():", platform.linux_distribution())
        print_("platform.linux_distribution(full_distribution_name=True):", platform.linux_distribution(full_distribution_name=True))
        print_("platform.linux_distribution(full_distribution_name=False):", platform.linux_distribution(full_distribution_name=False))
        dist_name, dist_version, dist_id = platform.linux_distribution(full_distribution_name=False)

    else:
        import distro

        print_("==================== distro.linux_distribution() ====================")
        print_("distro.linux_distribution():", distro.linux_distribution())
        print_("distro.linux_distribution(full_distribution_name=True):", distro.linux_distribution(full_distribution_name=True))
        print_("distro.linux_distribution(full_distribution_name=False):", distro.linux_distribution(full_distribution_name=False))
        dist_name, dist_version, dist_id = distro.linux_distribution(full_distribution_name=False)

    if dist_name.lower().startswith('centos') and dist_version.startswith('7'):
        print_("        CentOS 7")
    elif dist_name.lower().startswith('centos') and dist_version.startswith('6'):
        print_("        CentOS 6")
    elif dist_name.lower().startswith('ubuntu') and dist_version.startswith('18.04'):
        print_("        Ubuntu 18.04")
    elif dist_name.lower().startswith('raspbian'):
        if dist_id.startswith('buster'):
            print_("        Raspbian (buster)")
        elif dist_id.startswith('bionic'):
            print_("        Raspbian (bionic)")

Ergebnisdetails

x86_64 (AMD64) -Serie

Linux

Debian-System

Ubuntu

(1) Ubuntu 18.04

/etc/os-release


NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
(tips) $ uname -a
Linux ubuntu 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
(tips) $
(tips) $ python tips.py
==================== sys.version ====================
sys.version: 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='ubuntu', release='4.15.0-72-generic', version='#81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019', machine='x86_64')
os.uname()[0:]: ('Linux', 'ubuntu', '4.15.0-72-generic', '#81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019', 'x86_64')
sysname: "Linux", nodename: "ubuntu", release: "4.15.0-72-generic", version: "#81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019", machine: "x86_64"
sysname: "Linux", nodename: "ubuntu", release: "4.15.0-72-generic", version: "#81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019", machine: "x86_64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.15.0-72-generic-x86_64-with-Ubuntu-18.04-bionic
platform.platform(aliased=True, terse=True): Linux-4.15.0-72-generic-x86_64-with-glibc2.25
platform.platform(aliased=False, terse=False): Linux-4.15.0-72-generic-x86_64-with-Ubuntu-18.04-bionic
platform.platform(aliased=False, terse=True): Linux-4.15.0-72-generic-x86_64-with-glibc2.25
Linux-4.15.0-72-generic-x86_64-with-glibc2.25: Linux
==================== platform.*() ====================
platform.architecture(): ('64bit', 'ELF')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): x86_64
platform.node(): ubuntu
platform.processor(): x86_64
platform.python_build(): ('default', 'Nov  7 2019 10:44:02')
platform.python_compiler(): GCC 8.3.0
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.6.9
platform.python_version_tuple(): ('3', '6', '9')
platform.release(): 4.15.0-72-generic
platform.system(): Linux
platform.system_alias(): ('Linux', '4.15.0-72-generic', '#81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019')
platform.version(): #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019
platform.uname(): uname_result(system='Linux', node='ubuntu', release='4.15.0-72-generic', version='#81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019', machine='x86_64', processor='x86_64')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.25')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=True): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=False): ('ubuntu', '18.04', 'bionic')
        Ubuntu 18.04
(tips) $

(2) Ubuntu - Windows Subprocess for Linux (WSL)

/etc/os-release


NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
(tips) $ python tips.py
==================== sys.version ====================
sys.version: 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='localhost', release='4.4.0-18362-Microsoft', version='#476-Microsoft Fri Nov 01 16:53:00 PST 2019', machine='x86_64')
os.uname()[0:]: ('Linux', 'localhost', '4.4.0-18362-Microsoft', '#476-Microsoft Fri Nov 01 16:53:00 PST 2019', 'x86_64')
sysname: "Linux", nodename: "localhost", release: "4.4.0-18362-Microsoft", version: "#476-Microsoft Fri Nov 01 16:53:00 PST 2019", machine: "x86_64"
sysname: "Linux", nodename: "localhost", release: "4.4.0-18362-Microsoft", version: "#476-Microsoft Fri Nov 01 16:53:00 PST 2019", machine: "x86_64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.4.0-18362-Microsoft-x86_64-with-Ubuntu-18.04-bionic
platform.platform(aliased=True, terse=True): Linux-4.4.0-18362-Microsoft-x86_64-with-glibc2.25
platform.platform(aliased=False, terse=False): Linux-4.4.0-18362-Microsoft-x86_64-with-Ubuntu-18.04-bionic
platform.platform(aliased=False, terse=True): Linux-4.4.0-18362-Microsoft-x86_64-with-glibc2.25
Linux-4.4.0-18362-Microsoft-x86_64-with-glibc2.25: Linux
==================== platform.*() ====================
platform.architecture(): ('64bit', 'ELF')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): x86_64
platform.node(): localhost
platform.processor(): x86_64
platform.python_build(): ('default', 'Nov  7 2019 10:44:02')
platform.python_compiler(): GCC 8.3.0
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.6.9
platform.python_version_tuple(): ('3', '6', '9')
platform.release(): 4.4.0-18362-Microsoft
platform.system(): Linux
platform.system_alias(): ('Linux', '4.4.0-18362-Microsoft', '#476-Microsoft Fri Nov 01 16:53:00 PST 2019')
platform.version(): #476-Microsoft Fri Nov 01 16:53:00 PST 2019
platform.uname(): uname_result(system='Linux', node='localhost', release='4.4.0-18362-Microsoft', version='#476-Microsoft Fri Nov 01 16:53:00 PST 2019', machine='x86_64', processor='x86_64')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.25')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=True): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=False): ('ubuntu', '18.04', 'bionic')
        Ubuntu 18.04
(tips) $

(3) Ubuntu 19.04 Nicht implementiert

(4) Ubuntu 19.10 Nicht implementiert

(5) Ubuntu 20.04

/etc/os-release


NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
(tips) $ python tips.py
==================== sys.version ====================
sys.version: 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=8, micro=2, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='localhost', release='5.4.0-29-generic', version='#33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020', machine='x86_64')
os.uname()[0:]: ('Linux', 'localhost', '5.4.0-29-generic', '#33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020', 'x86_64')
sysname: "Linux", nodename: "localhost", release: "5.4.0-29-generic", version: "#33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020", machine: "x86_64"
sysname: "Linux", nodename: "localhost", release: "5.4.0-29-generic", version: "#33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020", machine: "x86_64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-5.4.0-29-generic-x86_64-with-glibc2.29
platform.platform(aliased=True, terse=True): Linux-5.4.0-29-generic-x86_64-with-glibc2.29
platform.platform(aliased=False, terse=False): Linux-5.4.0-29-generic-x86_64-with-glibc2.29
platform.platform(aliased=False, terse=True): Linux-5.4.0-29-generic-x86_64-with-glibc2.29
Linux-5.4.0-29-generic-x86_64-with-glibc2.29: Linux
==================== platform.*() ====================
platform.architecture(): ('64bit', 'ELF')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): x86_64
platform.node(): localhost
platform.processor(): x86_64
platform.python_build(): ('default', 'Apr 27 2020 15:53:34')
platform.python_compiler(): GCC 9.3.0
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.8.2
platform.python_version_tuple(): ('3', '8', '2')
platform.release(): 5.4.0-29-generic
platform.system(): Linux
platform.system_alias(): ('Linux', '5.4.0-29-generic', '#33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020')
platform.version(): #33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020
platform.uname(): uname_result(system='Linux', node='localhost', release='5.4.0-29-generic', version='#33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020', machine='x86_64', processor='x86_64')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.win32_edition(): None
platform.win32_is_iot(): False
platform.libc_ver(): ('glibc', '2.31')
platform.mac_ver() - macOS version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Ubuntu', '20.04', 'focal')
distro.linux_distribution(full_distribution_name=True): ('Ubuntu', '20.04', 'focal')
distro.linux_distribution(full_distribution_name=False): ('ubuntu', '20.04', 'focal')
(tips) $

RedHat-Serie

CentOS

(6) CentOS 6

/etc/redhat-release


CentOS release 6.10 (Final)
(tips) $ uname -a
Linux localhost.localdomain 2.6.32-754.el6.x86_64 #1 SMP Tue Jun 19 21:26:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
(tips) $
(tips) $ python tips.py
==================== sys.version ====================
sys.version: 3.6.8 (default, Aug 10 2019, 06:52:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=6, micro=8, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='localhost.localdomain', release='2.6.32-754.el6.x86_64', version='#1 SMP Tue Jun 19 21:26:04 UTC 2018', machine='x86_64')
os.uname()[0:]: ('Linux', 'localhost.localdomain', '2.6.32-754.el6.x86_64', '#1 SMP Tue Jun 19 21:26:04 UTC 2018', 'x86_64')
sysname: "Linux", nodename: "localhost.localdomain", release: "2.6.32-754.el6.x86_64", version: "#1 SMP Tue Jun 19 21:26:04 UTC 2018", machine: "x86_64"
sysname: "Linux", nodename: "localhost.localdomain", release: "2.6.32-754.el6.x86_64", version: "#1 SMP Tue Jun 19 21:26:04 UTC 2018", machine: "x86_64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-2.6.32-754.el6.x86_64-x86_64-with-centos-6.10-Final
platform.platform(aliased=True, terse=True): Linux-2.6.32-754.el6.x86_64-x86_64-with-glibc2.3.4
platform.platform(aliased=False, terse=False): Linux-2.6.32-754.el6.x86_64-x86_64-with-centos-6.10-Final
platform.platform(aliased=False, terse=True): Linux-2.6.32-754.el6.x86_64-x86_64-with-glibc2.3.4
Linux-2.6.32-754.el6.x86_64-x86_64-with-glibc2.3.4: Linux
==================== platform.*() ====================
platform.architecture(): ('64bit', 'ELF')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): x86_64
platform.node(): localhost.localdomain
platform.processor(): x86_64
platform.python_build(): ('default', 'Aug 10 2019 06:52:10')
platform.python_compiler(): GCC 4.4.7 20120313 (Red Hat 4.4.7-23)
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.6.8
platform.python_version_tuple(): ('3', '6', '8')
platform.release(): 2.6.32-754.el6.x86_64
platform.system(): Linux
platform.system_alias(): ('Linux', '2.6.32-754.el6.x86_64', '#1 SMP Tue Jun 19 21:26:04 UTC 2018')
platform.version(): #1 SMP Tue Jun 19 21:26:04 UTC 2018
platform.uname(): uname_result(system='Linux', node='localhost.localdomain', release='2.6.32-754.el6.x86_64', version='#1 SMP Tue Jun 19 21:26:04 UTC 2018', machine='x86_64', processor='x86_64')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.3.4')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('CentOS', '6.10', 'Final')
distro.linux_distribution(full_distribution_name=True): ('CentOS', '6.10', 'Final')
distro.linux_distribution(full_distribution_name=False): ('centos', '6.10', 'Final')
        CentOS 6
(tips) $

(7) CentOS 7

/etc/redhat-release


CentOS Linux release 7.7.1908 (Core)
(tips) $ uname -a
Linux localhost.localdomain 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
(tips) $
(tips) $ python tips.py
==================== sys.version ====================
sys.version: 3.6.8 (default, Aug  7 2019, 17:28:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=6, micro=8, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='localhost.localdomain', release='3.10.0-1062.el7.x86_64', version='#1 SMP Wed Aug 7 18:08:02 UTC 2019', machine='x86_64')
os.uname()[0:]: ('Linux', 'localhost.localdomain', '3.10.0-1062.el7.x86_64', '#1 SMP Wed Aug 7 18:08:02 UTC 2019', 'x86_64')
sysname: "Linux", nodename: "localhost.localdomain", release: "3.10.0-1062.el7.x86_64", version: "#1 SMP Wed Aug 7 18:08:02 UTC 2019", machine: "x86_64"
sysname: "Linux", nodename: "localhost.localdomain", release: "3.10.0-1062.el7.x86_64", version: "#1 SMP Wed Aug 7 18:08:02 UTC 2019", machine: "x86_64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-3.10.0-1062.el7.x86_64-x86_64-with-centos-7.7.1908-Core
platform.platform(aliased=True, terse=True): Linux-3.10.0-1062.el7.x86_64-x86_64-with-glibc2.3.4
platform.platform(aliased=False, terse=False): Linux-3.10.0-1062.el7.x86_64-x86_64-with-centos-7.7.1908-Core
platform.platform(aliased=False, terse=True): Linux-3.10.0-1062.el7.x86_64-x86_64-with-glibc2.3.4
Linux-3.10.0-1062.el7.x86_64-x86_64-with-glibc2.3.4: Linux
==================== platform.*() ====================
platform.architecture(): ('64bit', 'ELF')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): x86_64
platform.node(): localhost.localdomain
platform.processor(): x86_64
platform.python_build(): ('default', 'Aug  7 2019 17:28:10')
platform.python_compiler(): GCC 4.8.5 20150623 (Red Hat 4.8.5-39)
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.6.8
platform.python_version_tuple(): ('3', '6', '8')
platform.release(): 3.10.0-1062.el7.x86_64
platform.system(): Linux
platform.system_alias(): ('Linux', '3.10.0-1062.el7.x86_64', '#1 SMP Wed Aug 7 18:08:02 UTC 2019')
platform.version(): #1 SMP Wed Aug 7 18:08:02 UTC 2019
platform.uname(): uname_result(system='Linux', node='localhost.localdomain', release='3.10.0-1062.el7.x86_64', version='#1 SMP Wed Aug 7 18:08:02 UTC 2019', machine='x86_64', processor='x86_64')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.3.4')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('CentOS Linux', '7', 'Core')
distro.linux_distribution(full_distribution_name=True): ('CentOS Linux', '7', 'Core')
distro.linux_distribution(full_distribution_name=False): ('centos', '7', 'Core')
        CentOS 7
(tips) $

(8) CentOS 8 Nicht implementiert

(9) alpine on docker (on Ubuntu)

(test) # python tips.py
==================== sys.version ====================
sys.version: 3.8.2 (default, Feb 29 2020, 17:03:31)
[GCC 9.2.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=8, micro=2, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='82c7670dced4', release='4.15.0-88-generic', version='#88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020', machine='x86_64')
os.uname()[0:]: ('Linux', '82c7670dced4', '4.15.0-88-generic', '#88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020', 'x86_64')
sysname: "Linux", nodename: "82c7670dced4", release: "4.15.0-88-generic", version: "#88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020", machine: "x86_64"
sysname: "Linux", nodename: "82c7670dced4", release: "4.15.0-88-generic", version: "#88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020", machine: "x86_64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.15.0-88-generic-x86_64-with
platform.platform(aliased=True, terse=True): Linux-4.15.0-88-generic-x86_64-with
platform.platform(aliased=False, terse=False): Linux-4.15.0-88-generic-x86_64-with
platform.platform(aliased=False, terse=True): Linux-4.15.0-88-generic-x86_64-with
Linux-4.15.0-88-generic-x86_64-with: Linux
==================== platform.*() ====================
platform.architecture(): ('64bit', '')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): x86_64
platform.node(): 82c7670dced4
platform.processor():
platform.python_build(): ('default', 'Feb 29 2020 17:03:31')
platform.python_compiler(): GCC 9.2.0
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.8.2
platform.python_version_tuple(): ('3', '8', '2')
platform.release(): 4.15.0-88-generic
platform.system(): Linux
platform.system_alias(): ('Linux', '4.15.0-88-generic', '#88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020')
platform.version(): #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020
platform.uname(): uname_result(system='Linux', node='82c7670dced4', release='4.15.0-88-generic', version='#88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020', machine='x86_64', processor='')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.win32_edition(): None
platform.win32_is_iot(): False
platform.libc_ver(): ('', '')
platform.mac_ver() - macOS version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Alpine Linux', '3.11.3', '')
distro.linux_distribution(full_distribution_name=True): ('Alpine Linux', '3.11.3', '')
distro.linux_distribution(full_distribution_name=False): ('alpine', '3.11.3', '')
(test) #

Windows

(10) Windows Native Python on Windows 10 Home

(tips) C:\Users\...\tips.d>python tips.py
==================== sys.version ====================
sys.version: 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=8, micro=2, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: win32
win32: Windows
==================== os.name ====================
nt: Windows
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Windows-10-10.0.18362-SP0
platform.platform(aliased=True, terse=True): Windows-10
platform.platform(aliased=False, terse=False): Windows-10-10.0.18362-SP0
platform.platform(aliased=False, terse=True): Windows-10
Windows-10: Windows 10
==================== platform.*() ====================
platform.architecture(): ('64bit', 'WindowsPE')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): AMD64
platform.node(): localhost
platform.processor(): Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
platform.python_build(): ('tags/v3.8.2:7b3ab59', 'Feb 25 2020 23:03:10')
platform.python_compiler(): MSC v.1916 64 bit (AMD64)
platform.python_branch(): tags/v3.8.2
platform.python_implementation(): CPython
platform.python_revision(): 7b3ab59
platform.python_version(): 3.8.2
platform.python_version_tuple(): ('3', '8', '2')
platform.release(): 10
platform.system(): Windows
platform.system_alias(): ('Windows', '10', '10.0.18362')
platform.version(): 10.0.18362
platform.uname(): uname_result(system='Windows', node='localhost', release='10', version='10.0.18362', machine='AMD64', processor='Intel64 Family 6 Model 42 Stepping 7, GenuineIntel')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('10', '10.0.18362', 'SP0', '')
platform.win32_edition(): Core
platform.win32_is_iot(): False
platform.libc_ver(): ('', '')
platform.mac_ver() - macOS version: ('', ('', '', ''), '')

(tips) C:\Users\...\tips.d>

(11) Anaconda Python (Windows 10 Pro)

(PythonGeneralTest) >python tips.py
==================== sys.version ====================
sys.version: 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=7, micro=6, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: win32
win32: Windows
==================== os.name ====================
nt: Windows
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Windows-10-10.0.18362-SP0
platform.platform(aliased=True, terse=True): Windows-10
platform.platform(aliased=False, terse=False): Windows-10-10.0.18362-SP0
platform.platform(aliased=False, terse=True): Windows-10
Windows-10: Windows 10
==================== platform.*() ====================
platform.architecture(): ('64bit', 'WindowsPE')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): AMD64
platform.node(): localhost
platform.processor(): Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
platform.python_build(): ('default', 'Jan  8 2020 20:23:39')
platform.python_compiler(): MSC v.1916 64 bit (AMD64)
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.7.6
platform.python_version_tuple(): ('3', '7', '6')
platform.release(): 10
platform.system(): Windows
platform.system_alias(): ('Windows', '10', '10.0.18362')
platform.version(): 10.0.18362
platform.uname(): uname_result(system='Windows', node='localhost', release='10', version='10.0.18362', machine='AMD64', processor='Intel64 Family 6 Model 42 Stepping 7, GenuineIntel')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('10', '10.0.18362', 'SP0', '')
platform.libc_ver(): ('', '')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')

(PythonGeneralTest) >

UNIX

SunOS/Solaris

(12) Solaris 10 (x86_64)

$ uname -a
SunOS unknown 5.10 Generic_147148-26 i86pc i386 i86pc
$
$ python tips.py
==================== sys.version ====================
sys.version: 2.6.4 (r264:75706, Jun 26 2012, 21:27:36) [C]
==================== sys.version_info ====================
sys.version_info: (2, 6, 4, 'final', 0)
==================== sys.platform ====================
sys.platform: sunos5
sunos5: Solaris/SunOS
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): ('SunOS', 'unknown', '5.10', 'Generic_147148-26', 'i86pc')
os.uname()[0:]: ('SunOS', 'unknown', '5.10', 'Generic_147148-26', 'i86pc')
sysname: "SunOS", nodename: "unknown", release: "5.10", version: "Generic_147148-26", machine: "i86pc"
sysname: "SunOS", nodename: "unknown", release: "5.10", version: "Generic_147148-26", machine: "i86pc"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Solaris-2.10-i86pc-i386-32bit-ELF
platform.platform(aliased=True, terse=True): Solaris-2.10
platform.platform(aliased=False, terse=False): SunOS-5.10-i86pc-i386-32bit-ELF
platform.platform(aliased=False, terse=True): SunOS-5.10
Solaris-2.10: Solaris
        Solaris 10
==================== platform.*() ====================
platform.architecture(): ('32bit', 'ELF')
        sys.maxsize = 2147483647
        sys.maxsize > 2**32 --> False
platform.machine(): i86pc
platform.node():
platform.processor(): i386
platform.python_build(): ('r264:75706', 'Jun 26 2012 21:27:36')
platform.python_compiler(): C
platform.python_branch(): tags/r264
platform.python_implementation(): CPython
platform.python_revision(): 75706
platform.python_version(): 2.6.4
platform.python_version_tuple(): ('2', '6', '4')
platform.release(): 5.10
platform.system(): SunOS
platform.system_alias(): ('Solaris', '2.10', 'Generic_147148-26')
platform.version(): Generic_147148-26
platform.uname(): ('SunOS', '', '5.10', 'Generic_147148-26', 'i86pc', 'i386')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('libc', '1')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
platform.linux_distribution(): ('', '', '')
platform.linux_distribution(full_distribution_name=True): ('', '', '')
platform.linux_distribution(full_distribution_name=False): ('', '', '')
$

(13) Solaris 11.3 (x86_64)

$ uname -a
SunOS solaris11 5.11 11.3 i86pc i386 i86pc
$
$ python tips.py
==================== sys.version ====================
sys.version: 2.7.9 (default, Aug 19 2015, 19:06:46) [C]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: sunos5
sunos5: Solaris/SunOS
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): ('SunOS', 'solaris11', '5.11', '11.3', 'i86pc')
os.uname()[0:]: ('SunOS', 'solaris11', '5.11', '11.3', 'i86pc')
sysname: "SunOS", nodename: "solaris11", release: "5.11", version: "11.3", machine: "i86pc"
sysname: "SunOS", nodename: "solaris11", release: "5.11", version: "11.3", machine: "i86pc"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Solaris-2.11-i86pc-i386-32bit-ELF
platform.platform(aliased=True, terse=True): Solaris-2.11
platform.platform(aliased=False, terse=False): SunOS-5.11-i86pc-i386-32bit-ELF
platform.platform(aliased=False, terse=True): SunOS-5.11
Solaris-2.11: Solaris
        Solaris 11
==================== platform.*() ====================
platform.architecture(): ('32bit', 'ELF')
        sys.maxsize = 2147483647
        sys.maxsize > 2**32 --> False
platform.machine(): i86pc
platform.node(): solaris11
platform.processor(): i386
platform.python_build(): ('default', 'Aug 19 2015 19:06:46')
platform.python_compiler(): C
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 2.7.9
platform.python_version_tuple(): ('2', '7', '9')
platform.release(): 5.11
platform.system(): SunOS
platform.system_alias(): ('Solaris', '2.11', '11.3')
platform.version(): 11.3
platform.uname(): ('SunOS', 'solaris11', '5.11', '11.3', 'i86pc', 'i386')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('libc', '1')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
platform.linux_distribution(): ('', '', '')
platform.linux_distribution(full_distribution_name=True): ('', '', '')
platform.linux_distribution(full_distribution_name=False): ('', '', '')
$

FreeBSD

(14) FreeBSD 12.1

$ uname -a; freebsd-version -kru
FreeBSD freebsd001 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  amd64
12.1-RELEASE
12.1-RELEASE
12.1-RELEASE
$
(tips) $ python tips.py
==================== sys.version ====================
sys.version: 3.7.7 (default, Apr 23 2020, 01:19:26)
[Clang 8.0.1 (tags/RELEASE_801/final 366581)]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=7, micro=7, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: freebsd12
freebsd12: FreeBSD
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='FreeBSD', nodename='freebsd001', release='12.1-RELEASE', version='FreeBSD 12.1-RELEASE r354233 GENERIC', machine='amd64')
os.uname()[0:]: ('FreeBSD', 'freebsd001', '12.1-RELEASE', 'FreeBSD 12.1-RELEASE r354233 GENERIC', 'amd64')
sysname: "FreeBSD", nodename: "freebsd001", release: "12.1-RELEASE", version: "FreeBSD 12.1-RELEASE r354233 GENERIC", machine: "amd64"
sysname: "FreeBSD", nodename: "freebsd001", release: "12.1-RELEASE", version: "FreeBSD 12.1-RELEASE r354233 GENERIC", machine: "amd64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): FreeBSD-12.1-RELEASE-amd64-64bit-ELF
platform.platform(aliased=True, terse=True): FreeBSD-12.1-RELEASE
platform.platform(aliased=False, terse=False): FreeBSD-12.1-RELEASE-amd64-64bit-ELF
platform.platform(aliased=False, terse=True): FreeBSD-12.1-RELEASE
FreeBSD-12.1-RELEASE: Unknown
==================== platform.*() ====================
platform.architecture(): ('64bit', 'ELF')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): amd64
platform.node(): freebsd001
platform.processor(): amd64
platform.python_build(): ('default', 'Apr 23 2020 01:19:26')
platform.python_compiler(): Clang 8.0.1 (tags/RELEASE_801/final 366581)
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.7.7
platform.python_version_tuple(): ('3', '7', '7')
platform.release(): 12.1-RELEASE
platform.system(): FreeBSD
platform.system_alias(): ('FreeBSD', '12.1-RELEASE', 'FreeBSD 12.1-RELEASE r354233 GENERIC')
platform.version(): FreeBSD 12.1-RELEASE r354233 GENERIC
platform.uname(): uname_result(system='FreeBSD', node='freebsd001', release='12.1-RELEASE', version='FreeBSD 12.1-RELEASE r354233 GENERIC', machine='amd64', processor='amd64')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('libc', '7')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
(tips) $

ARM-Serie

(15) Raspberry Pi 3 B+ (raspbian/buster)

/etc/os-release


PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
(easytest) $ python tips.py
==================== sys.version ====================
sys.version: 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='localhost', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l')
os.uname()[0:]: ('Linux', 'localhost', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020', 'armv7l')
sysname: "Linux", nodename: "localhost", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
sysname: "Linux", nodename: "localhost", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.19.97-v7+-armv7l-with-debian-10.3
platform.platform(aliased=True, terse=True): Linux-4.19.97-v7+-armv7l-with-glibc2.28
platform.platform(aliased=False, terse=False): Linux-4.19.97-v7+-armv7l-with-debian-10.3
platform.platform(aliased=False, terse=True): Linux-4.19.97-v7+-armv7l-with-glibc2.28
Linux-4.19.97-v7+-armv7l-with-glibc2.28: Linux
==================== platform.*() ====================
platform.architecture(): ('32bit', 'ELF')
        sys.maxsize = 2147483647
        sys.maxsize > 2**32 --> False
platform.machine(): armv7l
platform.node(): localhost
platform.processor():
platform.python_build(): ('default', 'Dec 20 2019 18:57:59')
platform.python_compiler(): GCC 8.3.0
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.7.3
platform.python_version_tuple(): ('3', '7', '3')
platform.release(): 4.19.97-v7+
platform.system(): Linux
platform.system_alias(): ('Linux', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020')
platform.version(): #1294 SMP Thu Jan 30 13:15:58 GMT 2020
platform.uname(): uname_result(system='Linux', node='localhost', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l', processor='')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.28')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Raspbian GNU/Linux', '10', 'buster')
distro.linux_distribution(full_distribution_name=True): ('Raspbian GNU/Linux', '10', 'buster')
distro.linux_distribution(full_distribution_name=False): ('raspbian', '10', 'buster')
        Raspbian (buster)
(easytest) $

(16) docker Ubuntu 18.04 on Raspberry Pi Ubuntu/buster

/etc/os-release


NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
# python3 tips.py
==================== sys.version ====================
sys.version: 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='2be6fa454df5', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l')
os.uname()[0:]: ('Linux', '2be6fa454df5', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020', 'armv7l')
sysname: "Linux", nodename: "2be6fa454df5", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
sysname: "Linux", nodename: "2be6fa454df5", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.19.97-v7+-armv7l-with-Ubuntu-18.04-bionic
platform.platform(aliased=True, terse=True): Linux-4.19.97-v7+-armv7l-with-glibc2.25
platform.platform(aliased=False, terse=False): Linux-4.19.97-v7+-armv7l-with-Ubuntu-18.04-bionic
platform.platform(aliased=False, terse=True): Linux-4.19.97-v7+-armv7l-with-glibc2.25
Linux-4.19.97-v7+-armv7l-with-glibc2.25: Linux
==================== platform.*() ====================
platform.architecture(): ('32bit', 'ELF')
        sys.maxsize = 2147483647
        sys.maxsize > 2**32 --> False
platform.machine(): armv7l
platform.node(): 2be6fa454df5
platform.processor(): armv7l
platform.python_build(): ('default', 'Nov  7 2019 10:44:02')
platform.python_compiler(): GCC 8.3.0
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.6.9
platform.python_version_tuple(): ('3', '6', '9')
platform.release(): 4.19.97-v7+
platform.system(): Linux
platform.system_alias(): ('Linux', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020')
platform.version(): #1294 SMP Thu Jan 30 13:15:58 GMT 2020
platform.uname(): uname_result(system='Linux', node='2be6fa454df5', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l', processor='armv7l')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.25')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=True): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=False): ('ubuntu', '18.04', 'bionic')
        Ubuntu 18.04
#

(17) CentOS 7 on Docker on Raspbian Ubuntu/buster

/etc/os-release


NAME="CentOS Linux"
VERSION="7 (AltArch)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (AltArch)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

(tips) # python tips.py
==================== sys.version ====================
sys.version: 3.6.8 (default, Aug  7 2019, 17:16:12)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=6, micro=8, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='ca1a50e394ad', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l')
os.uname()[0:]: ('Linux', 'ca1a50e394ad', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020', 'armv7l')
sysname: "Linux", nodename: "ca1a50e394ad", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
sysname: "Linux", nodename: "ca1a50e394ad", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.19.97-v7+-armv7l-with-centos-7.6.1810-AltArch
platform.platform(aliased=True, terse=True): Linux-4.19.97-v7+-armv7l-with-glibc2.4
platform.platform(aliased=False, terse=False): Linux-4.19.97-v7+-armv7l-with-centos-7.6.1810-AltArch
platform.platform(aliased=False, terse=True): Linux-4.19.97-v7+-armv7l-with-glibc2.4
Linux-4.19.97-v7+-armv7l-with-glibc2.4: Linux
==================== platform.*() ====================
platform.architecture(): ('32bit', '')
        sys.maxsize = 2147483647
        sys.maxsize > 2**32 --> False
platform.machine(): armv7l
platform.node(): ca1a50e394ad
platform.processor(): armv7l
platform.python_build(): ('default', 'Aug  7 2019 17:16:12')
platform.python_compiler(): GCC 4.8.5 20150623 (Red Hat 4.8.5-39)
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.6.8
platform.python_version_tuple(): ('3', '6', '8')
platform.release(): 4.19.97-v7+
platform.system(): Linux
platform.system_alias(): ('Linux', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020')
platform.version(): #1294 SMP Thu Jan 30 13:15:58 GMT 2020
platform.uname(): uname_result(system='Linux', node='ca1a50e394ad', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l', processor='armv7l')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.4')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('CentOS Linux', '7', 'AltArch')
distro.linux_distribution(full_distribution_name=True): ('CentOS Linux', '7', 'AltArch')
distro.linux_distribution(full_distribution_name=False): ('centos', '7', 'AltArch')
        CentOS 7
(tips) #

(18) alpine on Docker on Raspbian

/etc/os-release


NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.6
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
# uname -a
Linux ef8a14447523 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l Linux
#
(tips) # python tips.py
==================== sys.version ====================
sys.version: 3.8.2 (default, Feb 29 2020, 17:03:31)
[GCC 9.2.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=8, micro=2, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='ef8a14447523', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l')
os.uname()[0:]: ('Linux', 'ef8a14447523', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020', 'armv7l')
sysname: "Linux", nodename: "ef8a14447523", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
sysname: "Linux", nodename: "ef8a14447523", release: "4.19.97-v7+", version: "#1294 SMP Thu Jan 30 13:15:58 GMT 2020", machine: "armv7l"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.19.97-v7+-armv7l-with
platform.platform(aliased=True, terse=True): Linux-4.19.97-v7+-armv7l-with
platform.platform(aliased=False, terse=False): Linux-4.19.97-v7+-armv7l-with
platform.platform(aliased=False, terse=True): Linux-4.19.97-v7+-armv7l-with
Linux-4.19.97-v7+-armv7l-with: Linux
==================== platform.*() ====================
platform.architecture(): ('32bit', '')
        sys.maxsize = 2147483647
        sys.maxsize > 2**32 --> False
platform.machine(): armv7l
platform.node(): ef8a14447523
platform.processor():
platform.python_build(): ('default', 'Feb 29 2020 17:03:31')
platform.python_compiler(): GCC 9.2.0
platform.python_branch():
platform.python_implementation(): CPython
platform.python_revision():
platform.python_version(): 3.8.2
platform.python_version_tuple(): ('3', '8', '2')
platform.release(): 4.19.97-v7+
platform.system(): Linux
platform.system_alias(): ('Linux', '4.19.97-v7+', '#1294 SMP Thu Jan 30 13:15:58 GMT 2020')
platform.version(): #1294 SMP Thu Jan 30 13:15:58 GMT 2020
platform.uname(): uname_result(system='Linux', node='ef8a14447523', release='4.19.97-v7+', version='#1294 SMP Thu Jan 30 13:15:58 GMT 2020', machine='armv7l', processor='')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.win32_edition(): None
platform.win32_is_iot(): False
platform.libc_ver(): ('', '')
platform.mac_ver() - macOS version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Alpine Linux', '3.11.6', '')
distro.linux_distribution(full_distribution_name=True): ('Alpine Linux', '3.11.6', '')
distro.linux_distribution(full_distribution_name=False): ('alpine', '3.11.6', '')
(tips) #

Bonus

Google Colaboratory

==================== sys.version ====================
sys.version: 3.6.9 (default, Apr 18 2020, 01:56:04) 
[GCC 8.4.0]
==================== sys.version_info ====================
sys.version_info: sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
==================== sys.platform ====================
sys.platform: linux
linux: Linux
==================== os.name ====================
posix: macOS, Linux or UNIX
==================== os.uname() ====================
os.uname(): posix.uname_result(sysname='Linux', nodename='26b82e7048b3', release='4.19.104+', version='#1 SMP Wed Feb 19 05:26:34 PST 2020', machine='x86_64')
os.uname()[0:]: ('Linux', '26b82e7048b3', '4.19.104+', '#1 SMP Wed Feb 19 05:26:34 PST 2020', 'x86_64')
sysname: "Linux", nodename: "26b82e7048b3", release: "4.19.104+", version: "#1 SMP Wed Feb 19 05:26:34 PST 2020", machine: "x86_64"
sysname: "Linux", nodename: "26b82e7048b3", release: "4.19.104+", version: "#1 SMP Wed Feb 19 05:26:34 PST 2020", machine: "x86_64"
==================== platform.platform() ====================
platform.platform(aliased=True, terse=False): Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic
platform.platform(aliased=True, terse=True): Linux-4.19.104+-x86_64-with-glibc2.25
platform.platform(aliased=False, terse=False): Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic
platform.platform(aliased=False, terse=True): Linux-4.19.104+-x86_64-with-glibc2.25
Linux-4.19.104+-x86_64-with-glibc2.25: Linux
==================== platform.*() ====================
platform.architecture(): ('64bit', '')
        sys.maxsize = 9223372036854775807
        sys.maxsize > 2**32 --> True
platform.machine(): x86_64
platform.node(): 26b82e7048b3
platform.processor(): x86_64
platform.python_build(): ('default', 'Apr 18 2020 01:56:04')
platform.python_compiler(): GCC 8.4.0
platform.python_branch(): 
platform.python_implementation(): CPython
platform.python_revision(): 
platform.python_version(): 3.6.9
platform.python_version_tuple(): ('3', '6', '9')
platform.release(): 4.19.104+
platform.system(): Linux
platform.system_alias(): ('Linux', '4.19.104+', '#1 SMP Wed Feb 19 05:26:34 PST 2020')
platform.version(): #1 SMP Wed Feb 19 05:26:34 PST 2020
platform.uname(): uname_result(system='Linux', node='26b82e7048b3', release='4.19.104+', version='#1 SMP Wed Feb 19 05:26:34 PST 2020', machine='x86_64', processor='x86_64')
platform.java_ver(): ('', '', ('', '', ''), ('', '', ''))
platform.win32_ver(): ('', '', '', '')
platform.libc_ver(): ('glibc', '2.25')
platform.mac_ver() - darwin version: ('', ('', '', ''), '')
==================== distro.linux_distribution() ====================
distro.linux_distribution(): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=True): ('Ubuntu', '18.04', 'bionic')
distro.linux_distribution(full_distribution_name=False): ('ubuntu', '18.04', 'bionic')
        Ubuntu 18.04

Zusammenfassung

Obwohl ich es untersucht habe, halte ich es für realistischer, die Gliederung anhand von "sys.platform" zu beurteilen und eine .conf-Datei usw. vorzubereiten und sie extern auf den Unterschied in der Verzeichnisstruktur usw. zu verweisen.

Ich hatte vor, es zu veröffentlichen, nachdem ich alle überprüft hatte, aber da ich alle habe, möchte ich nach Bedarf weitere veröffentlichen.

Recommended Posts

Plattform (OS) Beurteilung durch Python
Betriebssystembestimmung durch Makefile mit Python
Python-Betriebssystembetrieb
Mein Betriebssystem (Python)
Primzahlbeurteilung durch Python
Visualisierungsnotiz von Python
Beamformer-Antwort von Python
Spracherkennung durch Python MFCC
EXE Web API von Python
Parametereinstellung durch Python Configparser
Pin Python von Conda verwaltet
Keyword-Extraktion mit MeCab (Python)
Markov-Schaltmodell von Python
Bildverarbeitung mit Python (Pillow)
Python wurde von C-Programmierern gestartet
Informationen zu Python- und Betriebssystemoperationen
Sortieren nach Datum in Python
[Python] Sortierbar nach mehreren Bedingungen sortieren
Erweiterung des Python-Wörterbuchs um Argumente
Installieren Sie Python 3.8 unter Ubuntu 20.04 (Betriebssystemstandard)
Zusammenfassung des maschinellen Lernens von Python-Anfängern
Lerne Python durch Zeichnen (Turtle Graphics)
Python-Entwicklung unterstützt durch Jenkins-Unit-Test
Python SQL-Anweisung Nach Zeit extrahieren
Attributzugriff auf Python dict zulassen
Typisierungsautomatisierungsnotiz von Python-Anfängern
Python-Betriebssystemdateien, Unterverzeichnisoperationen
Installieren Sie Python 3.9 unter Ubuntu 20.04 (Betriebssystemstandard?)
Verhalten von Python3 durch Sakuras Server
Bestimmen des Betriebssystems, auf dem Python ausgeführt wird
Installieren Sie Python 2.7 unter Ubuntu 20.04 (Betriebssystemstandard?)
100 Sprachverarbeitung Knock Kapitel 1 von Python
Geschichte der Potenznäherung von Python
Sortieren von Dateien nach Namenskonvention mit Python