markdown pybluez填坑

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown pybluez填坑相关的知识,希望对你有一定的参考价值。

安装pybluez
安装libbluetooth-dev避免报错

sudo apt-get install libbluetooth-dev

安装pybluez

sudo apt-get install pybluez

例子:pybluz 查询蓝牙
```python
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))
```

1、import bluetooth 
报错:no module named bluetooth
原因及解决方法:

> You've installed the Python 2 version of the bluez bindings. Either run the script using 
python2 or install the Python 3 bindings. Since they aren't packaged, you would need to install them using pip:
python3 -m pip install pybluez

2、no module named gattlib
解决方法:
`sudo apt-get install libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev`

以上是关于markdown pybluez填坑的主要内容,如果未能解决你的问题,请参考以下文章

Python 连接蓝牙 python3.8 安装 pybluez

RFCOMM 没有在 Debian 上使用 PyBluez 配对?

pybluez 未检测到任何设备

python 尝试PyBluez

Arduino 和 PyBluez 之间的蓝牙通信

Windows下 python pybluez 安装使用记录