Install Python-Dbus in virtualenv

Go to your Venv follow this 2 steps :

sudo apt-get install libdbus-glib-1-dev libdbus-1-dev

pip install dbus-python

verify with:

pip freeze

if installed properly you will see: dbus-python==1.2.8


When pip tries to install a package, it looks for setup.py, which dbus-python doesn't have, so you'll have to download the source and compile it manually. Shouldn't be too hard:

PYTHON=python3.3 ./configure --prefix=/tmp/dbus-python
make
make install

then you can move the compiled files to your virtualenv.


edit: starting with dbus-python-1.2.2 (released 2016-02-22) dbus-python has a setup.py, so pip should be able to install it


My suggestion is to install the system package for the Python DBUS bindings and then create the virtualenv with the --system-site-packages command line option to enable access to the system-wide Python packages (including the dbus package) from the activated virtualenv. For example on Debian/Ubuntu (or a derived distribution):

$ sudo apt-get install python-dbus
$ virtualenv --system-site-packages dbus-venv

To use the built in Python 3 venv module instead of virtualenv:

$ sudo apt-get install python-dbus
$ sudo apt-get install python3-venv
$ python3 -m venv --system-site-packages my_venv