【问题标题】:Python3 dbus import error: undefined symbol: _Py_ZeroStructPython3 dbus 导入错误:未定义符号:_Py_ZeroStruct
【发布时间】:2018-04-22 09:29:20
【问题描述】:

我正在尝试将 python-mbus 用于 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 上运行

知道我做错了什么吗?

【问题讨论】:

  • 似乎_Py_ZeroStructPython3 中已消失(已替换)(我已在 3.5 上尝试过),但它仍可在 Python 2.7 上使用.所以,要么继续,要么在你的机器上针对 Python3 编译 python3-dbus (我认为源代码也必须进行一些修改)。或者等等……你安装的版本是什么? (将 --verbose 传递给 pip
  • 从 pip3 安装的版本:dbus-python-1.2.4,从包管理器安装:1.2.4-1+b4。
  • 嗯,我下载了 v1.2.4 的源代码,但它们没有引用该结构。这很奇怪......

标签: python linux python-3.x debian


【解决方案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 软件包通常是相同的。

【讨论】:

  • 不知何故...仅运行 aptitude update/remove 解决了该问题。不确定是否存在依赖问题(除了普通之外没有看到任何内容)或相关软件包已更新(我看到 python-gi 已升级)。但这解决了问题!谢谢myxhuang!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-22
  • 2016-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-03
相关资源
最近更新 更多