Check Linux distribution name

Here's what I found:

platform.linux_distribution

Tries to determine the name of the Linux OS distribution name.

It says platform.dist is deprecated since 2.6, you have to use platform.linux_distribution in Python 2 (but it is also deprecated in Python 3.5).


The reason because of which platform.linux_distribution does not identify some distributions is the non-standardized way distributions provide version-related information on themselves.

I've written a package called distro (now used by pip) which aims to replace distro.linux_distribution. It works on many distributions which might return weird or empty tuples when using platform.

https://github.com/nir0s/distro (distro, on pypi)

It provides a much more elaborate API to retrieve distribution related information.

$ python
Python 2.7.12 (default, Nov  7 2016, 11:55:55) 
[GCC 6.2.1 20160830] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import distro
>>> distro.linux_distribution()
(u'Antergos Linux', '', u'ARCHCODE')

By the way, platform.linux_distribution is to be removed in Python 3.7.

Tags:

Python

Linux