I am trying to use python-mbus for python 3, i have installed it with
sudo apt-get install python3-dbus
However the import fails with:
asdf@asdf:~$ python3 Python 3.6.3 (default, Oct 3 2017, 21:16:13) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import dbus Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/dist-packages/dbus/__init__.py", line 77, in <module> import dbus.types as types File "/usr/local/lib/python3.6/dist-packages/dbus/types.py", line 6, in <module> from _dbus_bindings import ( ImportError: /usr/local/lib/python3.6/dist-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
I have also installed it with:
pip3 uninstall dbus-python
But i still get the same error:
asdf@asdf:~$ python3 Python 3.6.3 (default, Oct 3 2017, 21:16:13) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import dbus Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/asdf/.local/lib/python3.6/site-packages/dbus/__init__.py", line 77, in <module> import dbus.types as types File "/home/asdf/.local/lib/python3.6/site-packages/dbus/types.py", line 6, in <module> from _dbus_bindings import ( ImportError: /home/asdf/.local/lib/python3.6/site-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
This is in sys.path:
>>> print (sys.path) ['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/asdf/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.6/dist-packages']
Im runnin on Debian GNU/Linux buster/sid
Any idea of what am I doing wrong?
Advertisement
Answer
I’m not exactly sure how I fixed this (can’t comment), but I had the exact same problem and I did:
sudo pip3 uninstall dbus-python sudo aptitude update && sudo aptitude upgrade sudo aptitude -f
After which aptitude alerted me of some dependency issues with Python, and I “downgraded” a version of Python I had installed on Ubuntu Xenial to the default package provided by Artful. Now, import dbus
on Python 3.6.3 doesn’t pass any errors. Don’t know if it actually works well, though.
Maybe you’ll be able to fix it in a similar fashion, since Debian and Ubuntu packages are usually the same.