Reputation: 13
OS:Ubuntu 20 python: 3.8.2 IDE:Pycharm CE
Generally speaking, situation is that I can import dbus in terminal via /usr/bin/python3, but I have to init my project in pycharm and tried to build a venv, which is based on interpreter(/usr/bin/python3).
However, in pycharm's terminal(venv activated), I failed to import dbus. But if I choose system interpreter directly without venv, everything is ok.
Already tried to copy dbus folder from system package root to venv but no effort. Don't think reinstall dbus-python can resolve this problem because it works fine in real-envi, and I've installed dbus-python in venv already.
Just wondering why... cause it's still a little trouble without venv.
Upvotes: 1
Views: 473
Reputation: 7994
There is a requirement with dbus-python to create the Python virtual environment with the --system-site-packages
because it is dependent on packages installed with a system package manager.
In Pycharm it means checking the Inherit global site-packages
box when creating the virtual environment.
You could look at using a different Python D-Bus binding that don't have the same dependency such as pydbus.
Upvotes: 3