How to solve ImportError: there is no module named "dbus"?

I installed anaconda4 on my ubuntu, and I have these modules in 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 none of them work!

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

 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 PyQT4 example , for which I don't have a tutorial.

What is the problem? Is this my setup or something else?

+6
source share
7 answers

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

 sudo apt-get install python-dbus 

I tried with a peak before, but this did not work for me.

+16
source

I'm not sure how you installed the modules, but this error most likely occurs because the module is not installed or not installed correctly. I would recommend the following to install the module.

pip install dbus

since you have anaconda, this will also work

conda install dbus

If you can access and download the source code, for example, on GitHub, you can try the following two methods. Go to the source code directory and run the following commands in the terminal:

 pip install setup.py 

or

 python setup.py build python setup.py install 

For more information on installing packages from source distributions, see this page .

+4
source

I had the same problem when installing notify2 in python3 I was allowed on macOS 10.12 using

 brew install dbus 
+2
source

Just do

 sudo apt-get install python-dbus 

on debian based os (ubuntu in your case) or

 brew install dbus 

on macOSX

+2
source

I had the same problem when starting an application called zeitgeist-explorer, but it was solved by installing python2-dbus, because the system used version 3.5 and version 2 for the application. check this post if you get an error similar to this fix import error without module named dbus

+1
source

Finally, I find another dbus solution on python, pyQt4 and pyQT5. The dbus library works fine on Linux ubuntu. several examples are presented at https://github.com/Werkov/PyQt4/tree/master/examples/dbus

and I could not solve python dbus errors! but it will do the trick. thanks for your help.

0
source

pydbus requires python-gi (or python3-gi in case of Python 3). And pydbus 0.2 is really deprecated, 0.5.1 is the current version.

0
source

All Articles