IanHarvey / bluepy

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

[Errno 13] Permission denied on bluepy-helper even though permissions are correctly set #482

Open ekatiyar opened 2 years ago

ekatiyar commented 2 years ago

I am running scan.py:

from bluepy.btle import Scanner, DefaultDelegate

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

    def handleDiscovery(self, dev, isNewDev, isNewData):
        if isNewDev:
            print("Discovered device", dev.addr)
        elif isNewData:
            print("Received new data from", dev.addr)

scanner = Scanner().withDelegate(ScanDelegate())
devices = scanner.scan(10.0)

for dev in devices:
    print("Device %s (%s), RSSI=%d dB".format(dev.addr, dev.addrType, dev.rssi))
    for (adtype, desc, value) in dev.getScanData():
        print("  %s = %s".format(desc, value)

but am getting this issue:

Traceback (most recent call last):
  File "/config/scan.py", line 14, in <module>
    devices = scanner.scan(10.0)
  File "/config/.local/lib/python3.9/site-packages/bluepy/btle.py", line 852, in scan
    self.start(passive=passive)
  File "/config/.local/lib/python3.9/site-packages/bluepy/btle.py", line 789, in start
    self._startHelper(iface=self.iface)
  File "/config/.local/lib/python3.9/site-packages/bluepy/btle.py", line 279, in _startHelper
    self._helper = subprocess.Popen(args,
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/config/.local/lib/python3.9/site-packages/bluepy/bluepy-helper'

As you can see, bluepy-helper has the widest possible permissions:

root@pi:/config# ls -la /config/.local/lib/python3.9/site-packages/bluepy/bluepy-helper
-rwxrwxrwx 1 abc users 858172 May  1 00:16 /config/.local/lib/python3.9/site-packages/bluepy/bluepy-helper

For some context I'm running this in a docker ocntainer for home assistant

maciej-napora commented 2 years ago

Try running it with sudo

https://stackoverflow.com/questions/39950254/permissionerror-errno-13-permission-denied-usr-lib-python3-5-site-package

https://stackoverflow.com/questions/31512422/pip-install-failing-with-oserror-errno-13-permission-denied-on-directory

Does this help?