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

Python3 dbus导入错误:未定义的符号:_Py_ZeroStruct,python,linux,python-3.x,debian,Python,Linux,Python 3.x,Debian,我正在尝试将PythonMBUS用于Python3,我已经安装了它 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. >>

我正在尝试将PythonMBUS用于Python3,我已经安装了它

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
但我还是得到了同样的错误:

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
Im在Debian GNU/Linux buster/sid上运行


你知道我做错了什么吗?

我不确定我是如何修复的(无法评论),但我遇到了完全相同的问题,我做到了:

sudo pip3 uninstall dbus-python
sudo aptitude update && sudo aptitude upgrade
sudo aptitude -f
之后,aptitude提醒我Python存在一些依赖性问题,我将安装在UbuntuXenial上的Python版本“降级”为Artful提供的默认包。现在,在Python3.6.3上导入dbus不会传递任何错误。不过,我不知道它是否真的有效


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

似乎Python3中的
\u Py\u ZeroStruct
已经消失(被替换)(我在3.5上尝试过),但它在Python2.7上仍然可用。所以,要么这样做,要么在您的机器上针对python3编译python3dbus(我认为源代码也需要修改一点)。或者等等。。。您安装的版本是什么?(pass--verbose to pip)从pip3:dbus-python-1.2.4和包管理器:1.2.4-1+b4.Hmm安装的版本,我下载了v1.2.4的源代码,它们没有引用该结构。真奇怪…不知怎么的。。。仅运行“能力倾向更新/删除”修复了该问题。不确定是否存在依赖性问题(除了普通版本外,没有看到任何其他内容)或者相关的软件包已经更新(我看到pythongi已经升级)。但这解决了问题!谢谢黄敏!
>>> 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']
sudo pip3 uninstall dbus-python
sudo aptitude update && sudo aptitude upgrade
sudo aptitude -f