简体   繁体   English

当我尝试在 python2.7 上导入蓝牙时出现错误

[英]Getting error when i try to import bluetooth on python2.7

I got python2.7 installed on a raspeberry pi 4 with a script which use the bluethooth library(pybluez) but the script was crashing when importing the library.我用一个使用蓝牙库(pybluez)的脚本在树莓派 4 上安装了 python2.7,但是在导入库时脚本崩溃了。 Si i simply try to import the bluetooth library on a python2.7 shell and i have the same error "AttributeEror: attribute ' doc ' of 'instancemethod' objects is not writable" Si 我只是尝试在 python2.7 shell 上导入蓝牙库,我有同样的错误“AttributeEror:‘instancemethod’对象的属性‘ doc ’不可写”

I can't switch to python3 and i don't understand why it's not working so if someone got an issue to this i would be grateful:)我无法切换到 python3,我不明白为什么它不起作用,所以如果有人对此有疑问,我将不胜感激:)

code:代码:

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

Thanks谢谢

i had the same issue and fixxed it by using this init .py我遇到了同样的问题并通过使用这个init .py 修复了它

somewhere near line 8 it says "version" and the "old" init.py i used was 0.23 the one working is 0.22.在第 8 行附近的某个地方,它说“版本”,而我使用的“旧”init.py 是 0.23,工作的是 0.22。 Btw i used pip install to get the 0.23.顺便说一句,我使用 pip install 来获得 0.23。

Another means to fix... Installed bluez with the following: sudo apt-get install bluetooth sudo apt-get install bluez libbluetooth-dev sudo python -m pip install pybluez另一种修复方法...使用以下命令安装 bluez: sudo apt-get install bluetooth sudo apt-get install bluez libbluetooth-dev sudo python -m pip install pybluez

and got this error.并得到这个错误。 fixed it by using python3 and installing pybluez with sudo python3 -m pip install pybluez通过使用 python3 并使用 sudo python3 -m pip install pybluez 安装 pybluez 来修复它

btw the install is based on: https://blog.adafruit.com/2020/04/17/starting-with-raspberry-pi-bluetooth-python-python-bluetooth-raspberrypi-piday-raspberry_pi/顺便说一句,安装基于: https ://blog.adafruit.com/2020/04/17/starting-with-raspberry-pi-bluetooth-python-python-bluetooth-raspberrypi-piday-raspberry_pi/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM