'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. 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"

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 :)

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



Solution 1:[1]

i had the same issue and fixxed it by using this 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. Btw i used pip install to get the 0.23.

Solution 2:[2]

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

and got this error. fixed it by using python3 and installing pybluez with sudo python3 -m pip install 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/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ZéroTwó
Solution 2 BessPtck