如何解决Pybluez OSerror

时间:2018-06-29 08:46:08

标签: python bluetooth

我想使用pybleuz将Lego Mindstorms NXT连接到我的Labtop。 但是当我搜索Mindstorms时,出现以下错误:

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')))

我得到了错误:

OSError                                   Traceback (most recent call last)
<ipython-input-8-bcb3970d611c> in <module>()
      4 
      5 nearby_devices = bluetooth.discover_devices(
----> 6         duration=8, lookup_names=True, flush_cache=True, lookup_class=False)
      7 
      8 print("found %d devices" % len(nearby_devices))

/usr/local/lib/python2.7/dist-packages/bluetooth/bluez.pyc in discover_devices(duration, flush_cache, lookup_names, lookup_class, device_id)
     24                       lookup_class=False, device_id=-1):
     25     if device_id == -1:
---> 26         device_id = _bt.hci_get_route()
     27 
     28     sock = _gethcisock (device_id)

OSError: [Errno 97] Address family not supported by protocol

有人可以帮助我吗?

0 个答案:

没有答案