Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while executing code #52

Open
guptva5 opened this issue Sep 1, 2020 · 5 comments
Open

Error while executing code #52

guptva5 opened this issue Sep 1, 2020 · 5 comments

Comments

@guptva5
Copy link

guptva5 commented Sep 1, 2020

Please let me know what i am missing. I used exact example code mentioned.

Traceback (most recent call last):
File "BluetoothSept012020.py", line 4, in
from beacontools import BeaconScanner, EddystoneTLMFrame, EddystoneFilter#, EddystoneUIDFrame, EddystoneURLFrame
File "/home/pi/.local/lib/python2.7/site-packages/beacontools/init.py", line 3, in
from .scanner import BeaconScanner
File "/home/pi/.local/lib/python2.7/site-packages/beacontools/scanner.py", line 17, in
from .device_filters import BtAddrFilter, DeviceFilter
File "/home/pi/.local/lib/python2.7/site-packages/beacontools/device_filters.py", line 110
raise ValueError("bt_addr({}) wasn't a string".format(bt_addr)) from exc
^
SyntaxError: invalid syntax

@tongclement
Copy link

You seem to be using python2.7. I think this library is intended for python3.

@tongclement
Copy link

You need to install python3 and when running, instead of python file.py, do python3. Also when doing pip package installations, you might have to call pip3 if pip doesn't seem to work. Try googling for more information. I understand, its frustrating :D Hope it helps.

@guptva5
Copy link
Author

guptva5 commented Sep 1, 2020

Thank you quick response. I tried python 3 also and here is new error....

Traceback (most recent call last):
File "BluetoothSept012020.py", line 13, in
packet_filter=EddystoneURLFrame
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/scanner.py", line 61, in init
self._mon = Monitor(callback, bt_device_id, device_filter, packet_filter, scan_parameters)
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/scanner.py", line 78, in init
self.backend = import_module('beacontools.backend')
File "/usr/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/backend/init.py", line 5, in
from .linux import *
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/backend/linux.py", line 2, in
from bluetooth import _bluetooth as bluez
ModuleNotFoundError: No module named 'bluetooth'

i used pip3 install beacontools

@guptva5
Copy link
Author

guptva5 commented Sep 1, 2020

So after this error .... i installed pybluez as well using below command.

python3 -m pip install pybluez

Now i am getting different error

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/scanner.py", line 119, in run
self.set_scan_parameters(**self.scan_parameters)
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/scanner.py", line 171, in set_scan_parameters
self.backend.send_cmd(self.socket, OGF_LE_CTL, OCF_LE_SET_SCAN_PARAMETERS, scan_parameter_pkg)
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/backend/linux.py", line 19, in send_cmd
return bluez.hci_send_cmd(socket, group_field, command_field, data)
_bluetooth.error: (1, 'Operation not permitted')

Traceback (most recent call last):
File "BluetoothSept012020.py", line 19, in
scanner.stop()
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/scanner.py", line 69, in stop
self._mon.terminate()
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/scanner.py", line 259, in terminate
self.toggle_scan(False)
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/scanner.py", line 181, in toggle_scan
self.backend.send_cmd(self.socket, OGF_LE_CTL, OCF_LE_SET_SCAN_ENABLE, command)
File "/home/pi/.local/lib/python3.7/site-packages/beacontools/backend/linux.py", line 19, in send_cmd
return bluez.hci_send_cmd(socket, group_field, command_field, data)
_bluetooth.error: (1, 'Operation not permitted')

@citruz
Copy link
Owner

citruz commented Sep 16, 2020

Did you execute this command from the readme?

# grant the python executable permission to access raw socket data
sudo setcap 'cap_net_raw,cap_net_admin+eip' "$(readlink -f "$(which python3)")"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants