IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.61k stars 490 forks source link

AttributeError: module 'bluepy' has no attribute 'Scanner' #470

Open yeshen4328 opened 2 years ago

yeshen4328 commented 2 years ago

when I run the demo, it shows error:

> $ python3 ./bluescan.py 
Traceback (most recent call last):
  File "./bluescan.py", line 2, in <module>
    scanner = bluepy.Scanner()
AttributeError: module 'bluepy' has no attribute 'Scanner'

> $ pip3 list               
Package                Version
---------------------- --------------------
attrs                  19.3.0
Automat                0.8.0
bcrypt                 3.2.0
blinker                1.4
bluepy                 1.3.0

code:

import bluepy
scanner = bluepy.Scanner()
devices = scanner.scan(timeout=3)
print('Found %d devices in %d seconds' % (len(devices), timeout))
for dev in devices:
        print('Name: ',dev.getValueText(9))
        print('Address: ', dev.addr)
w-xiaohei commented 2 years ago

from bluepy.btle import Scanner,DefaultDelegate

class ScanDelegate(DefaultDelegate): def init(self): DefaultDelegate.init(self)

scanner = Scanner().withDelegate(ScanDelegate()) timeout=3 devices = scanner.scan(timeout) print('Found %d devices in %d seconds' % (len(devices), timeout)) for dev in devices: print('Name: ',dev.getValueText(9)) print('Address: ', dev.addr)