I have to get the Linux distribution name from a Python script. There is a dist
method in the platform module:
import platform platform.dist()
But under my Arch Linux it returns:
>>> platform.dist() ('', '', '')
Why? How can I get the name?
PS. I have to check whether the distribution is Debian-based.
Update: I found here Python site, that dist() is deprecated since 2.6.
>>> platform.linux_distribution() ('', '', '')
Usually, Linux distributions include desktop environments, package management system, and a set of preinstalled applications. Some of the most popular Linux distributions are Debian, Red Hat, Ubuntu, Arch Linux, Fedora, CentOS, Kali Linux, OpenSUSE, Linux Mint, etc.
Open the terminal using “Show Applications” or with the keyboard shortcut [Ctrl] + [Alt] + [T]. Type the command “cat /etc/lsb-release” into the command line and press enter. The terminal shows the Ubuntu version you're running under “DISTRIB_RELEASE” and “DISTRIB_DESCRIPTION”.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With