【发布时间】: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_ZeroStruct在 Python3 中已消失(已替换)(我已在 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