0

Yesterday I installed my Raspberry Pi OS Lite (Debian Bullseye) using Raspberry Pi imager on my Mac. Everything in the most straightforward, up-to-date version.

Today I began working with Python. Installed pip using apt-get, then installed bluez for working with Bluetooth in Python. Install seemed OK. But here comes trouble. Any ideas?

pi@pi:~ $ sudo python3 -m pip install pybluez
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pybluez
  Downloading https://www.piwheels.org/simple/pybluez/PyBluez-0.23-cp39-cp39-linux_armv7l.whl (128 kB)
     |████████████████████████████████| 128 kB 324 kB/s 
Installing collected packages: pybluez
Successfully installed pybluez-0.23

pi@pi:~ $ python
Python 3.9.2 (default, Mar 12 2021, 04:06:34) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bluetooth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/bluetooth/__init__.py", line 45, in <module>
    from bluetooth.bluez import *
  File "/usr/local/lib/python3.9/dist-packages/bluetooth/bluez.py", line 8, in <module>
    import bluetooth._bluetooth as _bt
ImportError: libbluetooth.so.3: cannot open shared object file: No such file or directory
>>> 

Hardware: Raspberry Pi 3 Model B

4
  • 1
    The PyBluez project is not under active development and doesn't use the support BlueZ APIs. There may be better libraries to use depending on what you are trying to achieve.
    – ukBaz
    May 31, 2022 at 20:26
  • @ukBaz: That could be an answer :)
    – Seamus
    May 31, 2022 at 20:45
  • What do you mean "doesn't use the support BlueZ APIs"? Perhaps that it didn't survive the move to Python 3? And if this won't work... Do you know of any Python library currently usable under Linux and Python 3 that actually supports Bluetooth Low Energy (BLE)?
    – Joymaker
    May 31, 2022 at 23:29
  • There was a major change in the BlueZ APIs when it went from version 4 to version 5. More background information at: bluez.org/release-of-bluez-5-0. pypi.org/project/bleak seems to a popular library but it requires the use of asyncio which some people don't like. I've already done an answer talking about the different options: raspberrypi.stackexchange.com/a/114234/121848
    – ukBaz
    Jun 1, 2022 at 6:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.