Search code examples
pythonpackagedbus

I am getting error that dbus package is not installed in virtual env


I am using virtual env to run my program, but it show this error every time I run my code:

 UserWarning: The Python dbus package is not installed.
Try installing it with your distribution's package manager, it is usually called python-dbus or python3-dbus, but you might have to try dbus-python instead, e.g. when using pip.
  warnings.warn(msg)

I tried to install dbus package but it shows that its already installed on my system, so I tried running the code again, but, no luck - it shows the same error, that dbus isn't installed!


Solution

  • Using apt will install into dist-packages while using pip with a venv will install in to site-packages.

    If you create your venv with the --system-site-packages then that will pick up the apt package from dist-packages.

    If you do pip install dbus-python when a "normal" venv is active that should work also.