Install & Compatibility
Where this runs
tested against v0.3.1 · 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
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
notify2
✓ import notify2
✗ import notify2
This quickstart initializes `notify2`, creates a basic desktop notification with a summary, body, and icon, sets a timeout, and displays it. Requires a running DBus session and a notification daemon (e.g., dunst, xfce4-notifyd) on a Linux desktop environment.
import notify2
import os
# Initialize the notification system with your app name
# This is required before sending any notifications
notify2.init(os.environ.get('NOTIFY_APP_NAME', 'MyPythonApp'))
# Create a new notification
# Arguments: summary, body (optional), icon (optional)
n = notify2.Notification(
"Hello from notify2!",
"This is a test notification generated by a Python script.",
icon='dialog-information' # Example icon name (often from GTK/freedesktop theme)
)
# Set a timeout for the notification (in milliseconds)
# -1 means 'never expire' (if supported by daemon), 0 means 'default'
n.set_timeout(5000) # 5 seconds
# Show the notification
n.show()
print("Notification sent! Check your desktop.")
Debug
Known issues
gotchanotify2 relies on `dbus-python` and a running DBus session along with a compatible desktop notification daemon (e.g., `dunst`, `xfce4-notifyd`, `notification-daemon`) on a Linux desktop environment. If these prerequisites are not met, notifications will either silently fail to appear or raise `DBusException` errors.fixEnsure `dbus-python` is installed (`pip install dbus-python`) and a notification daemon is active and configured in your desktop environment. For server-side applications, this library is generally unsuitable.
affects: All versions
deprecatednotify2 is the spiritual successor to the older `pynotify` library. While both interfaces with `libnotify`, `notify2` is generally preferred for modern Python applications and offers a more Pythonic API. If migrating from `pynotify`, expect API changes.fixUpdate import statements and API calls from `pynotify` to `notify2`'s syntax (e.g., `notify2.Notification` instead of `pynotify.Notification`).
affects: Users migrating from `pynotify`
gotchaThe library's last update was in 2017 (version 0.3.1). While it generally remains functional, it might encounter subtle compatibility issues with very recent Python versions (e.g., Python 3.10+) or highly specific modern DBus configurations or desktop environments. It is not actively maintained.fixTest `notify2` thoroughly in your target environment. If persistent issues arise, consider exploring alternative notification mechanisms or newer Python libraries if available and maintained.
affects: Potentially Python 3.8+ and newer OS/DE versions
Upgrade
Version history
0.3.1latest on PyPI · released Apr 28, 2017
Audit
Dependencies
dbus-pythonrequiredCore dependency for DBus communication. Required for notifications to function.