TheWeirdDev / Bluetooth_Headset_Battery_Level

A python script to get battery level from Bluetooth headsets
GNU General Public License v3.0
760 stars 83 forks source link

SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats #88

Closed meetdilip closed 1 year ago

meetdilip commented 1 year ago

Hi,

Got this error in Ubuntu 22.04

python3 bluetooth_battery.py xx:xx:xx:xx:xx:xx
Traceback (most recent call last):
  File "/home/myname/Downloads/Bluetooth_Headset_Battery_Level-master/bluetooth_battery.py", line 166, in <module>
    main()
  File "/home/myname/Downloads/Bluetooth_Headset_Battery_Level-master/bluetooth_battery.py", line 163, in main
    print("Battery level for {} is {}".format(device, str(query)))
  File "/home/myname/Downloads/Bluetooth_Headset_Battery_Level-master/bluetooth_battery.py", line 93, in __str__
    return "{:.0%}".format(self._perform_query() / 100)
  File "/home/myname/Downloads/Bluetooth_Headset_Battery_Level-master/bluetooth_battery.py", line 105, in _perform_query
    sock.send(b"+BRSF: 1024")
  File "/home/myname/Downloads/Bluetooth_Headset_Battery_Level-master/bluetooth_battery.py", line 66, in send
    return super().send(b"\r\n" + data + b"\r\n")
  File "<string>", line 3, in send
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

I tried ./bluetooth_battery.py xx:xx:xx:xx:xx:xx

and

bluetooth_battery.py $(bluetoothctl info | awk '/^Device/ {print $2}')

commands too, without success. Any help would be great.

TheWeirdDev commented 1 year ago

Duplicate of #78 , follow the instructions in that thread.

meetdilip commented 1 year ago

Thanks. This command solved my issue

pip3 install git+https://github.com/pybluez/pybluez@master

Can see the battery percentage through the Gnome extension