Adam-Langley / pybleno

A direct port of the Bleno bluetooth LE peripheral role library to Python2/3
MIT License
68 stars 34 forks source link

Unable to run on Mac OS or Linux under WSL #46

Closed FPSUsername closed 4 years ago

FPSUsername commented 4 years ago

I am not sure if pybleno (and the bluetooth library) is supposed to work under non native Linux systems. I was trying to test if my program would run under other operating systems, but I got these tracebacks.

Mac OS

Python 3.8.2

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from pybleno import *
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/__init__.py", line 1, in <module>
    from .Bleno import Bleno
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/Bleno.py", line 5, in <module>
    from .hci_socket import Emit
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/__init__.py", line 1, in <module>
    from .Bindings import BlenoBindings
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/Bindings.py", line 4, in <module>
    from .Hci import Hci
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/Hci.py", line 5, in <module>
    from .BluetoothHCI import *
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/BluetoothHCI/__init__.py", line 3, in <module>
    from .BluetoothHCI import *
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothHCI.py", line 34, in <module>
    from .BluetoothSocket import BluetoothSocket
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothSocket.py", line 43, in <module>
    class BluetoothSocket(socket.socket):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothSocket.py", line 44, in BluetoothSocket
    libc = _libc_adapter()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothSocket.py", line 27, in __init__
    cdll.LoadLibrary("libc.so.6")
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libc.so.6, 6): no suitable image found.  Did find:
    file system relative paths not allowed in hardened programs

Windows Linux Subsystem

Python 3.6.9

Traceback (most recent call last):
  File "./main.py", line 8, in <module>
    bleno = Bleno()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/hci_socket/Emit.py", line 39, in new_init
    old_init(self, *k, **kw)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/Bleno.py", line 41, in __init__
    self._bindings = BlenoBindings()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/hci_socket/Emit.py", line 39, in new_init
    old_init(self, *k, **kw)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/hci_socket/Bindings.py", line 16, in __init__
    self._hci = Hci()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/hci_socket/Emit.py", line 39, in new_init
    old_init(self, *k, **kw)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/hci_socket/Hci.py", line 20, in __init__
    self._socket = BluetoothHCI(auto_start=False)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothHCI.py", line 239, in __init__
    self.hci = BluetoothHCISocketProvider(device_id)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothHCI.py", line 60, in __init__
    self._socket = BluetoothSocket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)
  File "/usr/lib/python3.6/socket.py", line 144, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol
Adam-Langley commented 4 years ago

Hi @FPSUsername - indeed while this is a port of Bleno which supports multiple platforms - this library has only been validated against Raspbian.

https://github.com/Adam-Langley/pybleno/blob/master/README.md