【问题标题】:Getting error when i try to import bluetooth on python2.7当我尝试在 python2.7 上导入蓝牙时出错
【发布时间】:2020-05-10 21:30:02
【问题描述】:

我在 raspeberry pi 4 上安装了 python2.7,其脚本使用了 bluethooth 库 (pybluez),但在导入库时脚本崩溃了。 我只是尝试在 python2.7 shell 上导入蓝牙库,我有同样的错误“AttributeEror: 'instancemethod' 对象的属性'doc'不可写”

我无法切换到 python3,我不明白为什么它不起作用,所以如果有人对此有疑问,我将不胜感激:)

代码:

Import bluetooth

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/bluetooth/__init__.py", line 282,
in <module>
"""
AtributeError: attribute '__doc__' of 'instancemethod' objects is not writable

谢谢

【问题讨论】:

  • 不清楚您使用的是什么代码。 https://github.com/karulis/pybluez/blob/master/bluetooth/__init__.py 甚至没有第 282 行。
  • 是的对不起,我只是想导入我在 python shell 中运行的库“蓝牙”,然后我收到了从“Traceback”开始的消息。
  • bluetooth 不在标准库中,因此您一定是从某个地方安装了代码。如果我们不知道那是什么代码,我们将无法帮助您。
  • 我做了“sudo apt-get install python-bluez”来安装库
  • 也许我弄错了我不知道的版本.. 我的 github 上有代码("init") --> github.com/mathieu-gouleau/prd

标签: python bluetooth pybluez


【解决方案1】:

我遇到了同样的问题并使用this init.py 修复了它

在第 8 行附近的某个地方,它显示“版本”,而我使用的“旧”init.py 是 0.23,而工作的是 0.22。 顺便说一句,我使用 pip install 来获取 0.23。

【讨论】:

    猜你喜欢
    • 2021-09-06
    • 1970-01-01
    • 2022-11-21
    • 2014-10-24
    • 2020-05-20
    • 2017-05-29
    • 2014-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多