As of September 2017, this project is deprecated. Use https://github.com/nir0s/distro instead.
Py-osinfo should work without any extra programs or libraries, beyond what your OS provides. The goal is for this to work on every OS that Python supports. Works on Linux, OS X, Windows, BSD, Solaris, Cygwin, and Haiku.
pip install py-osinfo
$ python osinfo/osinfo.py
type: Linux
brand: Slackware
release: 14.1
kernel: (3, 13, 0)
from osinfo import osinfo
os_type, os_brand, os_release, os_kernel = osinfo.get_os_info()
if os_type in osinfo.OSType.linux:
print("Looks like you're using Linux.")
if os_kernel < (3, 13, 1):
print("Your Linux kernel version is too old!")
if os_brand in osinfo.OSBrand.CentOS:
print("Looks like you're using CentOS.")
if os_release == '99.01':
print("OMG CentOS from 2099. Can I see the source code?")
Arch
type: Linux
brand: Arch
release:
kernel: (3, 10, 9)
CentOS
type: Linux
brand: CentOS
release: 6.5
kernel: (2, 6, 32)
Cygwin
type: Cygwin
brand: CYGWIN_NT-6.3
release: 1.7.32
kernel: (1, 7, 32)
Crunch Bang
type: Linux
brand: CrunchBang
release: 11
kernel: (3, 2, 0)
Debian
type: Linux
brand: Debian
release: 7.6
kernel: (3, 2, 0)
Debian BSD
type: BSD
brand: Debian
release: 8.0-1-486
kernel: (8, 0)
elementary
type: Linux
brand: elementary
release: 0.2.1
kernel: (3, 2, 0)
Fedora 20
type: Linux
brand: Fedora
release: 20
kernel: (3, 16, 2)
FreeBSD 10
type: BSD
brand: FreeBSD
release: 10.0
Haiku
type: BeOS
brand: Haiku
release: 1
kernel: (1,)
Linux Mint
type: Linux
brand: LinuxMint
release: 17
kernel: (3, 13, 0)
Mageia
type: Linux
brand: Mageia
release: 2
kernel: (3, 4, 69)
Mandriva
type: Linux
brand: Mandriva
release: 2009.1
kernel: (2, 6, 29)
Manjaro
type: Linux
brand: Manjaro
release: 0.8.10
kernel: (3, 12, 20)
Milax
type: Solaris
brand: Milax
release: Milax_0.3.2
kernel: (5, 11)
Mac OS X
type: MacOS
brand: OSX
release: 10.9.4
kernel: (13, 3, 0)
NetBSD
type: BSD
brand: NetBSD
release: 6.1.4
Nexenta
type: Solaris
brand: Nexenta
release: NexentaOS_20081207
kernel: (5, 11)
Open Indiana
type: Solaris
brand: OpenIndiana
release: 151a8
kernel: (5, 11)
Open Solaris
type: Solaris
brand: OpenSolaris
release: svn_111b
kernel: (5, 11)
open SUSE
type: Linux
brand: openSUSE
release: 13.1
kernel: (3, 11, 10)
Open SXCE
type: Solaris
brand: OpenSXCE
release: pensxce2014.05__illumos20140505
kernel: (5, 11)
PCBSD
type: BSD
brand: FreeBSD
release: 10.0-release-p13
Redhat
type: Linux
brand: Redhat
release: 6.5
kernel: (2, 6, 32)
Sabayon
type: Linux
brand: Sabayon
release: 5.5
kernel: (2, 6, 37)
Scientific Linux
type: Linux
brand: ScientificLinux
release: 6.5
kernel: (2, 6, 32)
Slackware
type: Linux
brand: Slackware
release: 13.0.0.0.0
kernel: (2, 6, 29)
Ubuntu 14.04
type: Linux
brand: Ubuntu
release: 14.04
kernel: (3, 13, 0)
Windows 7
type: Windows
brand: Windows7
release: 6.1.7601
kernel: (6, 1, 7601)
Windows 8
type: Windows
brand: Windows8
release: 6.2.9200
kernel: (6, 2, 9200)
Windows XP
type: Windows
brand: WindowsXP
release: 5.1.2600
kernel: (5, 1, 2600)
Please submit a pull request with the results for your favorite OS!
Please report a Bug if you suspect any of this information is wrong.