{"id":9983,"library":"notify2","title":"notify2 - DBus Desktop Notifications","description":"notify2 is a Python interface to DBus notifications, allowing applications to send desktop notifications via the freedesktop.org Desktop Notifications Specification. It provides a simple API to initialize an application, create notifications with summaries, bodies, and icons, and control their display. The current version is 0.3.1, released in 2017. The project appears to be in maintenance mode, with no new feature development expected.","status":"maintenance","version":"0.3.1","language":"en","source_language":"en","source_url":"https://github.com/mikeboers/notify2","tags":["notifications","dbus","desktop","linux"],"install":[{"cmd":"pip install notify2","lang":"bash","label":"Install notify2"}],"dependencies":[{"reason":"Core dependency for DBus communication. Required for notifications to function.","package":"dbus-python","optional":false}],"imports":[{"symbol":"notify2","correct":"import notify2"},{"symbol":"Notification","correct":"n = notify2.Notification(...)"}],"quickstart":{"code":"import notify2\nimport os\n\n# Initialize the notification system with your app name\n# This is required before sending any notifications\nnotify2.init(os.environ.get('NOTIFY_APP_NAME', 'MyPythonApp'))\n\n# Create a new notification\n# Arguments: summary, body (optional), icon (optional)\nn = notify2.Notification(\n    \"Hello from notify2!\", \n    \"This is a test notification generated by a Python script.\",\n    icon='dialog-information' # Example icon name (often from GTK/freedesktop theme)\n)\n\n# Set a timeout for the notification (in milliseconds)\n# -1 means 'never expire' (if supported by daemon), 0 means 'default'\nn.set_timeout(5000) # 5 seconds\n\n# Show the notification\nn.show()\nprint(\"Notification sent! Check your desktop.\")","lang":"python","description":"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."},"warnings":[{"fix":"Ensure `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.","message":"notify2 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update import statements and API calls from `pynotify` to `notify2`'s syntax (e.g., `notify2.Notification` instead of `pynotify.Notification`).","message":"notify2 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.","severity":"deprecated","affected_versions":"Users migrating from `pynotify`"},{"fix":"Test `notify2` thoroughly in your target environment. If persistent issues arise, consider exploring alternative notification mechanisms or newer Python libraries if available and maintained.","message":"The 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.","severity":"gotcha","affected_versions":"Potentially Python 3.8+ and newer OS/DE versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install a desktop notification daemon (e.g., `sudo apt install notification-daemon` or `dunst`) and ensure it's running and accessible to your user session.","cause":"No desktop notification daemon is running on the system or it's not properly registered with DBus.","error":"dbus.exceptions.DBusException: The name org.freedesktop.Notifications was not provided by any .service files"},{"fix":"Install `dbus-python` using pip: `pip install dbus-python`. On some systems, this might require system-level DBus development libraries (e.g., `libdbus-1-dev` and `libdbus-glib-1-dev` on Debian/Ubuntu).","cause":"The `dbus-python` package, a core dependency for DBus communication, is not installed.","error":"ImportError: No module named 'dbus'"},{"fix":"1. Ensure `notify2.init(\"AppName\")` is called at the beginning of your script. 2. Verify your notification daemon is active and check its logs for errors. 3. Check your system's notification settings and ensure they are not globally disabled. 4. Try a simple example from the quickstart to isolate the issue.","cause":"This is often a silent failure indicating that the notification daemon is not properly configured, not running, or the desktop environment is suppressing notifications. This can also happen if the `notify2.init()` call is missing or incorrect.","error":"Notification doesn't appear on screen, with no error messages in the terminal."}]}