Python3 dbus导入错误:未定义符号:_Py_ZeroStruct

时间:2017-11-09 11:42:49

标签: python linux python-3.x debian

我正在尝试使用python-mbus for python 3,我已经用

安装了它
sudo apt-get install python3-dbus

然而导入失败了:

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

我还安装了它:

pip3 uninstall dbus-python

但我仍然得到同样的错误:

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

这是在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']

我在Debian GNU / Linux buster / sid上运行

知道我做错了什么?

1 个答案:

答案 0 :(得分:1)

我不确定我是如何解决此问题(无法评论),但我遇到了完全相同的问题而且我做了:

sudo pip3 uninstall dbus-python
sudo aptitude update && sudo aptitude upgrade
sudo aptitude -f

之后,aptitude提醒我一些Python的依赖问题,并且我将我在Ubuntu Xenial上安装的Python版本“降级”为Artful提供的默认包。现在,Python 3.6.3上的import dbus没有传递任何错误。不过,不知道它是否真的有效。

也许你可以用类似的方式修复它,因为Debian和Ubuntu软件包通常都是一样的。