直接安装pybluez的时候报错了
In file included from bluez/btmodule.c:20:0:
bluez/btmodule.h:5:33: fatal error: bluetooth/bluetooth.h: No such file or directory
google后的结果是没有安装libbluetooth-dev
sudo apt-get install libbluetooth-dev
sudo pip install pybluez
直到看到Successfully installed pybluez
,安装成功
官方的示例inquiry.py
import bluetooth
print("performing inquiry...")
nearby_devices = bluetooth.discover_devices(lookup_names = True)
print("found %d devices" % len(nearby_devices))
for addr, name in nearby_devices:
print(" %s - %s" % (addr, name))
查找了手机的蓝牙
⚙ ubuntu@ubuntu ~ python findblue.py
performing inquiry...
found 1 devices
28:CF:E9:1C:42:2A - phodal
原文参考:https://www.phodal.com/blog/raspberry-pi-bluetooth-use-python-and-pybluez/ 致敬
希望对你有帮助。