Distro Info
The `distro-info` library provides Python modules and data files with comprehensive information about Debian and Ubuntu distributions, including codenames, versions, release dates, and end-of-life dates. It is maintained by the Ubuntu Developers and is currently at version 1.0. Releases are stable and generally align with Debian/Ubuntu development cycles, focusing on data updates rather than frequent API changes.
Common errors
-
ImportError: cannot import name 'get_current' from 'distro_info'
cause Attempting to import functions directly from the top-level `distro_info` package instead of its specific submodules.fixFunctions like `get_current` are located in submodules. Import them correctly: `from distro_info.ubuntu import get_current` or `from distro_info.debian import get_distro_info`. -
My code shows 'Ubuntu Focal Fossa' but I'm on Fedora!
cause Misunderstanding the library's purpose. `distro-info` provides static data *about* Debian/Ubuntu distros, not dynamic detection of the host OS.fixThis library is designed for querying Debian and Ubuntu distribution details. If you need to detect the operating system your Python code is running on, use a different library like the `distro` package (note: no `-info` suffix) or standard library modules like `platform`. -
SyntaxError: Missing parentheses in call to 'print'
cause Running `distro-info` (especially version 1.0 or newer) with a Python 2 interpreter. Version 1.0 dropped Python 2 support.fixEnsure your Python environment is using Python 3 (specifically, Python 3.6+ is recommended for `distro-info` 1.0+). Upgrade your interpreter if needed.
Warnings
- breaking Python 2 support was dropped in `distro-info` version 1.0. Attempting to use this version with a Python 2 interpreter will result in SyntaxErrors or similar compatibility issues.
- gotcha This library provides hardcoded data about Debian and Ubuntu distributions. It does NOT detect the host operating system you are running on. If you use it on a Fedora, CentOS, macOS, or any non-Debian/Ubuntu system, it will still return data specific to Debian/Ubuntu, not your actual OS.
- gotcha The main functions like `get_current()` and `get_distro_info()` are located within specific submodules (`distro_info.ubuntu` or `distro_info.debian`), not directly available from the top-level `distro_info` package.
Install
-
pip install distro-info
Imports
- get_current
from distro_info import get_current
from distro_info.ubuntu import get_current
- get_distro_info
from distro_info import get_distro_info
from distro_info.debian import get_distro_info
Quickstart
from distro_info.ubuntu import get_current, get_distro_info
# Get information about the current Ubuntu development series
current_ubuntu = get_current()
print(f"Current Ubuntu Series: {current_ubuntu.series} ({current_ubuntu.codename})")
print(f"Release Date: {current_ubuntu.release_date}")
print(f"Support until: {current_ubuntu.eol_date}")
# Get information for a specific Debian codename
debian_stretch = get_distro_info(codename='stretch')
if debian_stretch:
print(f"\nDebian Stretch Version: {debian_stretch.version}")
print(f"Debian Stretch Codename: {debian_stretch.codename}")
else:
print("\nCould not find Debian 'stretch' information.")