Skip to content Skip to sidebar Skip to footer

How To Use Python Dbus Bindings In Anaconda

I am trying to install dbus on Anaconda python environment and I am struggling. Here is the error message I am getting: e@gateway:~$ python Python 3.5.4 |Anaconda custom (64-bit)|

Solution 1:

I had similar issues, there are few cases where dbus and python don't work well out-of-the-box. The consensus appears to be that you need a system-level install (i.e. apt-get) to get dbus to work. I believe the /home/e/anaconda3/lib/python3.5/site-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct error you're seeing is directly related to that.

conda install dbus does not add anything to ~/anaconda3/lib/python3.6/site-packages, but instead appears to install some executables in ~/anaconda3/bin/ like dbus-run-session, dbus-daemon, etc. This makes some sense when you analyze the contents of the dbus tarball https://anaconda.org/conda-forge/dbus, as it's all C files and executables. I'm not sure it's supposed to be the dbus python module, but I could be wrong.

EDIT:

I searched the conda repositories and found a few individuals that uploaded a version of dbus-python, presumably that they compiled and installed. I tried this one out in a py3.6 conda environment via:

conda install -c scottwales dbus-python

I was then able to import dbus. This is a hacky approach and should not be used in production, I'd recommend listening to Carlos Cordoba's post below. But if you need a solution now, search through some user conda packages or try to compile the library yourself.

Solution 2:

Can anyone help me? Am I missing something blatantly obvious here?

Yes, you are. There's one thing people still don't understand about conda: conda is not a pip replacement. It is a general package manager, in the same vein as apt-get, yum, brew, emerge, etc, but cross-platform and based on Python.

In this case, that means that conda install dbus does not install the Python Dbus bindings, as you would expect with pip . It installs the Dbus C package itself, which is needed by Qt 5 (again, the C++ library, not the Python bindings to it).

Unfortunately, there are no Conda packages for dbus-python. To make matters worse, it seems there's no easy way to create packages for it, as pointed out here.

Finally, you said

Here is the error message I am getting

The (most probable) cause of that error is because you added your system Python dist-packages path to the PYTHONPATH of Anaconda or because you blindly copied the dbus module from system Python to Anaconda. Please don't do that ever again. System Python and Anaconda packages are compiled with different compilers and under different conditions. So mixing them is the cause of incomprehensible errors, just like the one you reported.

Post a Comment for "How To Use Python Dbus Bindings In Anaconda"