skillfed

systemd-python

Python interface for libsystemd

systemd-python v235 954.6K downloads/30d#4,649 on PyPI521
Copyleft license LGPLv2+ Active released

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-python

uv

uv add systemd-python

poetry

poetry add systemd-python

Installing 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

License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)Programming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Logging

Tags

systemd journal logging pythonlibsystemd python bindingsjournalctl python interfacesystemd daemon socket activationlinux system logging pythonsystemd machine id queriesjournald structured logging
systemd-integrationlinux-onlycompiled-extension

More Python Modules packages