Python Pybluez找不到设备,但bluetoothctl可以

Python Pybluez找不到设备,但bluetoothctl可以,python,bluetooth,pybluez,Python,Bluetooth,Pybluez,我一直在尝试在运行Ubuntu18的联想y50-70笔记本电脑上运行一个简单的python蓝牙示例。但是在这样做的时候,我注意到Pybluez库找不到任何设备,而使用bluetoothctl工具可以 import bluetooth print("performing inquiry...") nearby_devices = bluetooth.discover_devices(duration=8, lookup_names=True, flush_cache=True, lookup_c

我一直在尝试在运行Ubuntu18的联想y50-70笔记本电脑上运行一个简单的python蓝牙示例。但是在这样做的时候,我注意到Pybluez库找不到任何设备,而使用bluetoothctl工具可以

import bluetooth
print("performing inquiry...")
nearby_devices = bluetooth.discover_devices(duration=8, 
lookup_names=True, flush_cache=True, lookup_class=False)

print("found %d devices" % len(nearby_devices))

for addr, name in nearby_devices:
try:
    print("  %s - %s" % (addr, name))
except UnicodeEncodeError:
    print("  %s - %s" % (addr, name.encode('utf-8', 'replace')))
运行上面的代码将给出一个输出:
找到0个设备
。运行bluetoothctl时,我得到以下输出:

[NEW] Controller 40:B8:9A:44:E0:46 daan-Lenovo-Y50-70 [default]
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller 40:B8:9A:44:E0:46 Discovering: yes
[NEW] Device 30:AE:A4:37:A2:4A 30-AE-A4-37-A2-4A
[NEW] Device D0:D2:B0:91:1C:C5 D0-D2-B0-91-1C-C5
[NEW] Device 70:73:CB:DF:1B:08 70-73-CB-DF-1B-08
[NEW] Device 51:80:89:6F:6E:B6 51-80-89-6F-6E-B6
[bluetooth]#

我已经尝试以root用户身份运行python脚本,当前的pybluez版本是0.22。我希望任何人都知道如何解决这个问题。

您找到解决方案了吗?我也处在同样的情况下,所以分享我很抱歉,伙计。我还没有找到解决办法。在整个项目期间,我不得不使用手机调试蓝牙应用程序:-(好的,谢谢你。