systemd-python
Python interface for libsystemd
What it is and what it does
systemd-python is a native Python interface to systemd's C libraries on Linux. It wraps four main systemd subsystems: journal (sending structured messages and reading journal files), daemon (socket activation and daemon utilities), id128 (machine and boot identifiers), and login (querying sessions, users, and seats). The package is designed for applications that need to integrate deeply with systemd's logging and service infrastructure.
The module is typically installed via distribution packages (dnf, apt, pacman, zypper) rather than PyPI, since it requires compilation against system libsystemd headers. When building from source, you must have the systemd development libraries and a C compiler available. Once installed, it allows Python code to send structured log entries to the journal, read journal entries with filtering and time-based queries, and query systemd's session and machine metadata—all without shelling out to journalctl or other command-line tools.
Use it for:
- Send structured application logs directly to systemd journal with custom fields instead of writing to files.
- Read and filter systemd journal entries programmatically by executable, process ID, unit name, or time range.
- Integrate Python daemons with systemd socket activation and service lifecycle management.
- Query machine identifiers, boot IDs, and systemd message catalog entries for system introspection.
- Route Python logging framework output to systemd journal using the provided JournalHandler.
- Query active login sessions, users, and seats on a systemd-managed system.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python bindings to systemd's native C libraries for journal logging, daemon management, machine identification, and login session queries on Linux systems.
Yes, if you are writing systemd-integrated services on Linux and need native journal access or daemon integration. The package is actively maintained and has no known vulnerabilities. However, the high install friction (requires libsystemd dev headers and compilation) and the lack of recent PyPI releases mean you should prefer distribution packages where available. Not suitable for non-systemd systems or cross-platform Python applications.
Install
systemd-python on PyPI
pip
pip install systemd-pythonuv
uv add systemd-pythonpoetry
poetry add systemd-pythonInstalling systemd-python
Before you install
High install friction: requires compilation against libsystemd development headers and system libraries. The package is actively maintained (last commit 2026-06-19) but has not had a PyPI release since 2023-02-11, so building from source is often necessary. Distribution packages (dnf, apt, pacman) are recommended where available.
License in practice
Licensed under LGPLv2+, a copyleft license. Derivative works and modifications must be distributed under compatible terms, and source code must be made available to recipients.
Quickstart
from systemd import journal
journal.send('Hello world')
journal.send('Message', FIELD='value')
from systemd import journal
from datetime import datetime, timedelta
j = journal.Reader()
j.seek_realtime(datetime.now() - timedelta(minutes=20))
for entry in j:
print(entry['MESSAGE'])
Requires libsystemd development headers and C compiler installed; on Debian/Ubuntu: apt install libsystemd-dev gcc python3-dev pkg-config; on Fedora: dnf install systemd-devel gcc python3-devel.
Verify before relying
- Whether the package works on non-systemd Linux distributions or other Unix-like systems.
- Current Python version support range (classifiers list both Python 2 and 3, but Python 2 is EOL).
- Whether prebuilt wheels are available for common distributions or if source compilation is always required.
Package facts
| License | LGPLv2+ (copyleft) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 1,280 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 954,641/month — #4,649 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: systemd-python-235.tar.gz
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
cysystemdCython-based wrapper for systemd's libsystemd…
permissive · top 15,000 on PyPI
sdbusPython library for D-Bus communication with…
copyleft · top 15,000 on PyPI
sdnotifySends systemd service notifications (startup…
permissive · top 15,000 on PyPI
pycupsProvides Python bindings to the CUPS printing…
copyleft · top 15,000 on PyPI
lib-log-richProvides Rich-styled colored console logging…
permissive · top 15,000 on PyPI
pidManages process ID files with stale detection,…
permissive · top 15,000 on PyPI
daemonizeDaemonize provides a Python library for…
permissive · top 15,000 on PyPI
python-logging-lokiA Python logging handler that sends log records…
permissive · top 5,000 on PyPI
xrootdProvides Python bindings to XRootD, a…
copyleft · top 5,000 on PyPI
certifi-linuxRedirects certifi's certificate lookup to use…
permissive · top 15,000 on PyPI