sudo apt-get install libglib2.0-devpip3 install pybluez
3 测试库是否安装正确ipython3In [1]: import bluetooth
安装报错compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
解决方法sudo apt-get install libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-devpython3 -m pip install pybluez
如上操作完成后,所需要的环境搭建完成 PC 端 ubuntu 下python bluetooth 操控蓝牙应用代码示例 1 扫描附近的蓝牙设备ipython3In [1]: import bluetoothIn [2]: devs= bluetooth.discover_devices(duration=8,lookup_names=True, )In [3]: print(devs)