Python 3.6.4 dbus导入错误

问题描述 投票:2回答:2

在我的sys.path中添加/ usr / lib / python3 / dist-packages之后,正如有人在另一篇文章中建议的那样,当我尝试在python3中导入dbus时,我现在收到错误:

>>> import dbus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/dbus/__init__.py", line 82, in <module>
    import dbus.types as types
  File "/usr/lib/python3/dist-packages/dbus/types.py", line 6, in <module>
    from _dbus_bindings import (
ModuleNotFoundError: No module named '_dbus_bindings'

我尝试用apt重新安装python3-dbus,但无济于事。在尝试完全重置我的python3-dbus时,我甚至不得不在意外卸载dbus而不是python3-dbus后重新安装我的操作系统。我甚至从源代码安装了Python 3.6.4。任何帮助都表示赞赏,因为我完全不知道为什么这不起作用。

我的/ usr / lib / python3 / dist-packages / dbus /目录中的文件:

bus.py         exceptions.py                lowlevel.py  service.py
_compat.py     _expat_introspect_parser.py  mainloop     types.py
connection.py  gi_service.py                proxies.py   _version.py
_dbus.py       glib.py                      __pycache__
decorators.py  __init__.py                  server.py

在我看来,python试图从文件_dbus_bindings.py导入,但它不存在。我在网上查看了这个错误,并没有找到任何有用的东西。

python-3.x ubuntu-16.04 dbus
2个回答
0
投票

如果您通过ppa安装了数据包'python3.6',就像这里解释的那样:http://ubuntuhandbook.org/index.php/2017/07/install-python-3-6-1-in-ubuntu-16-04-lts,那么您可以使用以下命令将命令python3切换回指向版本3.5的python:

sudo update-alternatives --config python3

我有启动unity-tweak-tool的问题,它依赖于python 3.5并且给了我“没有名为'_dbus_bindings'的模块'错误。这个解决方案有所帮助,虽然它剥夺了你的python 3.6。


0
投票

我通过以下方式解决了这个问题

pip3 install dbus-python
© www.soinside.com 2019 - 2024. All rights reserved.