TheWeirdDev / Bluetooth_Headset_Battery_Level

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

PY_SSIZE_T_CLEAN macro must be defined for '#' formats #78

Closed ghost closed 2 years ago

ghost commented 2 years ago

Well, it looks like some functions in code are deprecated now

I get this message:

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

When I run:

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

Using Python:

Python 3.10.4

On Distro:

Arch Linux 5.17.3-zen1-1-zen

My comment:

While I was searching solution, I found this on stackoverflow. It looks like smth is outdated in your code

TheWeirdDev commented 2 years ago

It's not something in my code. The bluez library needs to be updated for Python 3.10. Read this comment for more info.

TheWeirdDev commented 2 years ago

Try the docker image and see if it works well.

loureirorg commented 2 years ago

For those installing on Ubuntu 22.04:

# install pybluez, a requirement library
pip3 install setuptools==58
pip3 install git+https://github.com/pybluez/pybluez@master

# install bluetooth_battery
pip3 install bluetooth_battery

tl;dr; I just ran into the same issue on Ubuntu 22.04.

The pybluez library fixed the issue on Jan 2, 2020, but they didn't release a new version of the package.

So, if you use pip to install it, it will install the old version without the fix.

To install the library with the fix, you can use this command:

pip3 install git+https://github.com/pybluez/pybluez@master
ivnish commented 2 years ago

Thanks loureirorg!