Registry / devops / distro

distro

JSON →
library1.9.0pypypi✓ verified 52d ago

Distro is a Python library that provides information about the operating system distribution it runs on, such as a reliable machine-readable ID and version information. It serves as a recommended replacement for Python's original platform.linux_distribution function, which was removed in Python 3.8. The current version is 1.9.0, released on October 5, 2023. The library is actively maintained with a stable release cadence, with the latest release being v1.9.0.

devops
pip install distro
Install & Compatibility
Where this runs
tested against v1.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.058s · 17.9MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.5s · import 0.048s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

distro
import distro
Ensure correct import path to access the library's functions.

A simple script to print the distribution ID, version, and name using the Distro library.

import distro print(distro.id()) print(distro.version()) print(distro.name())
Debug
Known issues
breakingThe platform.linux_distribution function was removed in Python 3.8. Distro serves as its recommended replacement.
fix
Use Distro's id(), version(), and name() functions instead.
affects: >=3.8
deprecatedPython 2.7, 3.4, and 3.5 support was deprecated in Distro v1.6.0.
fix
Upgrade to Python 3.6 or later.
affects: >=1.6.0
gotchaRunning pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead.
fix
Use a virtual environment instead (https://pip.pypa.io/warnings/venv). If running pip as root is intentional and its implications are understood, use the --root-user-action option to suppress this warning.
affects: >=3.6
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'distro'
The 'distro' library has not been installed in your Python environment or is not accessible within your current Python path.
fix
Install the 'distro' library using pip: `pip install distro`
AttributeError: module 'platform' has no attribute 'linux_distribution'
The `platform.linux_distribution()` function was deprecated in Python 3.5 and removed in Python 3.8, and code or dependencies are still attempting to use it. The `distro` library is its recommended replacement.
fix
Install the 'distro' library (`pip install distro`) and replace calls to `platform.linux_distribution()` with `distro.linux_distribution()`, or preferably with `distro.id()`, `distro.name()`, and `distro.version()` for more granular information.
distro.linux_distribution() is deprecated
The `distro.linux_distribution()` function itself has been deprecated in `distro` version 1.6.0 and later, in favor of more specific accessor functions.
fix
Replace `distro.linux_distribution()` calls with `distro.id()`, `distro.version()`, and `distro.name()` to retrieve specific distribution information.
AttributeError: module 'distro' has no attribute 'id'
This error typically occurs if an older version of the `distro` library is installed that does not yet include the `id()` (or `version()`, `name()`) consolidated accessor functions, or if there is a typo in the function call.
fix
Ensure you have a recent version of the `distro` library installed: `pip install --upgrade distro`. If the error persists, double-check the function name for typos.
AttributeError: module 'distro' has no attribute 'linux_distribution'
The `distro` library's API does not include a `linux_distribution` method; it uses distinct methods like `id()` or `name()`.
fix
Replace `distro.linux_distribution()` with appropriate `distro` API calls such as `distro.id()`, `distro.name()`, or `distro.version()`.
Upgrade
Version history
1.9.0latest on PyPI
Audit
Dependencies
platformrequiredProvides access to underlying platform information; required for functionality.
Agent activity
15 hits · last 30 days
node
6
seranking-bot
4
ahrefsbot
2
amazonbot
1
bytedance
1
Resources