'Python lightblue : "AttributeError: module 'lightblue' has no attribute 'finddevices'"
.
Hi everyone, hope you're doing well!
I am trying to write a Python (3.8.9) script so that my computer detects every Bluetooth device it can find and provides me with the list of devices it has found.
Then, I installed pybluez and lightblue with
pip3 install pybluez
and
pip3 install python-lightblue
python-lightblue has the version 1.0.3.
Now, here's my code :
import bluetooth
def scan():
print("Scanning for bluetooth devices:")
devices = bluetooth.discover_devices(lookup_names = True, lookup_class = True)
number_of_devices = len(devices)
print(number_of_devices," devices found")
for addr, name, device_class in devices:
print("\n")
print("Device:")
print("Device Name: %s" % (name))
When I run this, I get the following mistake :
Traceback (most recent call last):
File "bluetooth_detect.py", line 16, in <module>
scan()
File "bluetooth_detect.py", line 5, in scan
devices = bluetooth.discover_devices(lookup_names = True, lookup_class = True)
File "/Users/<my_name>/Library/Python/3.8/lib/python/site-packages/bluetooth/macos.py", line 12, in discover_devices
devices = lightblue.finddevices(getnames=lookup_names, length=duration)
AttributeError: module 'lightblue' has no attribute 'finddevices'
Yet, when I check the documentation on the Internet, the module lightblue does have the attribute finddevices, and I can't find any mention of this problem on another forum (maybe I didn't look up long enough ?)
Would anyone have any idea ? Thank you in advance ! :-)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
