python platform doesn't recognized Ubuntu distribution

473 views Asked by At

When I run a compiled by hand Python3, platform.linux_distribution() doesn't recognize Ubuntu distribution and think it's a Debian :

$ /opt/python3.4/bin/python3.4
>>> import platform
>>> platform.linux_distribution()
('debian', 'jessie/sid', '')

But when I use the Python3 shipped with Ubuntu, I get :

$ /usr/bin/python3
>>> import platform
>>> platform.linux_distribution()
('Ubuntu', '14.04', 'trusty')

What do we need to make it recognize Ubuntu distributions?

1

There are 1 answers

0
samb On

Ubuntu fixes it for himself in the file /usr/lib/python3.4/platform.py by checking first the content of the file /etc/lsb-release before looking for files /etc/*[-_][release|version]. This prevent from thinking this is a Debian (as said by the file /etc/debian_version) when it's in fact an Ubuntu (which is based on Debian).

I could fix it by patching that file with the one provided on an Ubuntu.