Reputation: 671
I'm trying to use dbus in a python3 project, but when I try to import it, I get an error:
>>> import dbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'dbus'
So I tried to fix it by making sure dbus is installed for my python 3.6 installation but it seems to already be installed:
$ sudo apt-get install python3-dbus
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-dbus is already the newest version (1.2.0-3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I'm able to import dbus in python 2.7 without any problems, but my python3 can't seem to find the module even though it shows that it's already installed. My which python3
shows it's installed in /usr/local/bin/python3
Upvotes: 5
Views: 4910
Reputation: 21
You are probably getting this error because the path to the module installed by apt-get
is not in your sys.path
. One solution you can try is this:
import sys
sys.path.insert(0, "/usr/lib/python3/dist-packages")
import dbus
Upvotes: 2