{"id":8077,"library":"dbus-python","title":"dbus-python Bindings","description":"dbus-python provides Python bindings for libdbus, the reference implementation of the D-Bus inter-process communication (IPC) system. It enables Python applications to expose objects on the D-Bus and to invoke methods on objects exposed by other applications. The current version is 1.4.0, and releases are infrequent, typically aligned with updates to the underlying D-Bus specification or libdbus.","status":"active","version":"1.4.0","language":"python","source_language":"en","source_url":"https://github.com/freedesktop/dbus-python","tags":["dbus","ipc","linux","bindings","inter-process communication"],"install":[{"cmd":"pip install dbus-python","lang":"bash","label":"Install with pip"},{"cmd":"sudo apt install python3-dbus # Debian/Ubuntu\nsudo dnf install python3-dbus # Fedora\nsudo pacman -S python-dbus # Arch","lang":"bash","label":"Install via OS package manager (recommended)"}],"dependencies":[],"imports":[{"symbol":"dbus","correct":"import dbus"},{"note":"While functional, `import dbus.service` is idiomatic to keep `dbus` namespace clear.","wrong":"from dbus import service","symbol":"dbus.service","correct":"import dbus.service"},{"note":"You typically need the specific mainloop class, not just the module.","wrong":"import dbus.mainloop","symbol":"dbus.mainloop.glib.DBusGMainLoop","correct":"from dbus.mainloop.glib import DBusGMainLoop"}],"quickstart":{"code":"import dbus\n\ntry:\n    # Connect to the system bus\n    # Use dbus.SessionBus() for the user's session bus\n    bus = dbus.SystemBus()\n    \n    # Get the D-Bus 'org.freedesktop.DBus' interface on the bus\n    obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')\n    \n    # Get the 'org.freedesktop.DBus' interface itself\n    iface = dbus.Interface(obj, 'org.freedesktop.DBus')\n    \n    # Call the ListNames method to get active service names\n    names = iface.ListNames()\n    \n    print(\"Currently active D-Bus service names (system bus):\")\n    for name in names:\n        print(f\"- {name}\")\n\nexcept dbus.exceptions.DBusException as e:\n    print(f\"Error connecting to D-Bus or listing names: {e}\")\n    print(\"Ensure the D-Bus daemon is running and you have appropriate permissions.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart connects to the system D-Bus and queries the `org.freedesktop.DBus` service to list all currently active service names. This demonstrates basic bus connection, object retrieval, and method invocation. For services that require asynchronous operations (e.g., listening for signals or exposing Python objects), integration with a main event loop (like GLib or Qt) is necessary."},"warnings":[{"fix":"Ensure your project runs on Python 3. For Python 2 compatibility, you would need to use an older `dbus-python` version which is not recommended or maintained.","message":"dbus-python 1.x is Python 3 ONLY. Older versions (e.g., 0.8x) supported Python 2. Directly upgrading from an old Python 2 environment will break existing code.","severity":"breaking","affected_versions":"< 1.0.0 to >= 1.0.0"},{"fix":"Install `libdbus` via your operating system's package manager (e.g., `libdbus-1-dev` or `dbus-libs` on Linux distributions). Using `apt install python3-dbus` (or equivalent) usually installs both the Python bindings and the necessary system libraries.","message":"dbus-python requires the underlying C library `libdbus` to be installed on the system. `pip install dbus-python` will install the Python package but will fail at runtime if `libdbus` is missing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Import and initialize a mainloop: `from dbus.mainloop.glib import DBusGMainLoop; DBusGMainLoop(set_as_default=True)`. Then run the GLib main loop: `from gi.repository import GLib; loop = GLib.MainLoop(); loop.run()` or similar for other toolkits.","message":"For D-Bus services that emit signals or require asynchronous handling (e.g., exposing Python objects), `dbus-python` must be integrated with an event loop (e.g., GLib, Qt, Gtk). Without it, your D-Bus service will not respond to calls or process signals.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with the D-Bus specification and common usage patterns. The `dbus-python` documentation and the official D-Bus tutorial are good starting points.","message":"D-Bus concepts (Bus, Object Paths, Interfaces, Service Names) are fundamental. Misunderstanding these often leads to connection errors or services not being found.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.4.0':53 'align':59 'applic':30,48 'bind':4,10,74 'bus':20,38,67 'communic':24,78 'current':50 'd':19,37,66 'd-bus':18,36,65 'dbus':2,6,71 'dbus-python':1,5 'enabl':28 'expos':32,45 'implement':15 'infrequ':57 'inter':22,76 'inter-process':21,75 'invok':41 'ipc':25,72 'libdbus':12,70 'linux':73 'method':42 'object':33,44 'process':23,77 'provid':8 'python':3,7,9,29 'refer':14 'releas':55 'specif':68 'system':26 'typic':58 'under':64 'updat':61 'version':51","created_at":"2026-04-16T17:00:19.056555+00:00","updated_at":"2026-04-16T17:00:19.056555+00:00","problems":{"verify_error":"× Failed to build `dbus-python==1.4.0`\n  ├─▶ The build backend returned an error\n  ╰─▶ Call to `mesonpy.build_wheel` failed (exit status: 1)\n\n      [stdout]\n      + meson setup\n      /home/xor/.cache/uv/sdists-v9/pypi/dbus-python/1.4.0/KibWgaO_b5sCbB5mF3d6x/src\n      /home/xor/.cache/uv/sdists-v9/py"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.4.0","cli_name":"","cli_version":null,"type":"library","homepage":"http://www.freedesktop.org/wiki/Software/DBusBindings/#python","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/dbus-python/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}