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()
('', '', '')
uname -a
return on Arch? platform.py is 1600 lines of trying everything they could think of to distinguish various systems; it is a huge pile of heuristics. Arch also appears to be based only on itself, no other distro: en.wikipedia.org/wiki/Arch_Linux – Stuntlsb_release -is
return under Arch? Ifplatform.dist()
gives you no usable data maybe you can callsubprocess.check_output(["lsb_release","-is"])
instead. – Sloshy