How solve ImportError: No module named 'dbus'?

B nM picture B nM · May 30, 2016 · Viewed 57.9k times · Source

I have installed anaconda4 on my ubuntu and I have these modules on my Python:

dbus-python (1.2.4)

gi (1.2)

pydbus (0.2)

QtAwesome (0.3.2)
qtconsole (4.2.0)
QtPy (1.0)

sip (4.18)

I tried installing dbus-python (1.2.4) and pydbus (0.2), however, neither of them works!

After testing a simple program in python 3.5.1, an error appeared:

import dbus
system_bus = dbus.SystemBus()

ImportError: No module named 'dbus'

When I use pydbus in Python 2.7.11 and 3.5.1:

from pydbus import SystemBus

bus = SystemBus()
systemd = bus.get(".systemd1")

for unit in systemd.ListUnits():
    print(unit)

I get this error:

ImportError: No module named repository

The only thing that works is this example with PyQT4 which I don't have any tutorial for.

What is the problem? Is it my installation or something else?

Answer

Amit Chahar picture Amit Chahar · Jun 20, 2016

I don't know about installing dbus in anaconda but you can install it using apt-get in ubuntu .

sudo apt-get install python-dbus

I tried with pip earlier but that didn't work for me.