Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Linux distribution name

Tags:

python

linux

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() ('', '', '') 
like image 523
Max Frai Avatar asked May 03 '10 07:05

Max Frai


People also ask

What is Linux distribution name?

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.

How do I find my Ubuntu distribution name?

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”.


1 Answers

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).

like image 107
nc3b Avatar answered Oct 04 '22 20:10

nc3b