ds4drv icon indicating copy to clipboard operation
ds4drv copied to clipboard

module 'socket' has no attribute 'AF_BLUETOOTH'

Open SebastianPfliegel opened this issue 7 years ago • 7 comments

This is the output which gets triggered as soon as I try to pair the device:

[info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event21 (evdev) 
[info][bluetooth] Scanning for devices
[info][bluetooth] Found device A4:53:85:38:DB:02
Traceback (most recent call last):
  File "/usr/bin/ds4drv", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/ds4drv/__main__.py", line 154, in main
    for device in backend.devices:
  File "/usr/lib/python3.6/site-packages/ds4drv/backends/bluetooth.py", line 132, in devices
    device = self.find_device()
  File "/usr/lib/python3.6/site-packages/ds4drv/backends/bluetooth.py", line 121, in find_device
    return BluetoothDS4Device.connect(bdaddr)
  File "/usr/lib/python3.6/site-packages/ds4drv/backends/bluetooth.py", line 23, in connect
    ctl_socket = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET,
AttributeError: module 'socket' has no attribute 'AF_BLUETOOTH'

Any idea on how to fix this? Thanks in advance. Btw, using openSUSE Tumbleweed.

SebastianPfliegel avatar Apr 26 '18 15:04 SebastianPfliegel

must be an opensuse problem same error message here since this is from 4 months ago without a response im assuming there is no fix so far is there?

roadh0use avatar Aug 17 '18 02:08 roadh0use

I'm having the same problem on Ubuntu 18.04

LuxMiranda avatar Mar 30 '19 22:03 LuxMiranda

Update: I was able to fix the problem by just cloning the repo and installing from source. Seems like it might just be the version of ds4drv installed through pip that is the issue.

LuxMiranda avatar Apr 01 '19 18:04 LuxMiranda

@JackMiranda same here with Ubuntu 18.04

smoothdvd avatar Oct 16 '19 11:10 smoothdvd

Your problem is that the python version you are using does have proper Bluetooth support! I had the same problem when installed python from source and did not have libbluetooth-dev package installed on my system! So, install libbluetooth-dev (or something similar in other than Debian), and reinstall python. The easiest way to check it is working is to fireup a python console from terminal and try this:

from socket import AF_BLUETOOTH

cslev avatar Sep 15 '20 00:09 cslev

Having the same problem on arch with the newest bluez-utils-compat release

[info][bluetooth] Scanning for devices
[info][bluetooth] Found device A4:AE:12:AD:5B:C6
Traceback (most recent call last):
  File "/usr/bin/ds4drv", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/ds4drv/__main__.py", line 154, in main
    for device in backend.devices:
  File "/usr/lib/python3.9/site-packages/ds4drv/backends/bluetooth.py", line 132, in devices
    device = self.find_device()
  File "/usr/lib/python3.9/site-packages/ds4drv/backends/bluetooth.py", line 121, in find_device
    return BluetoothDS4Device.connect(bdaddr)
  File "/usr/lib/python3.9/site-packages/ds4drv/backends/bluetooth.py", line 23, in connect
    ctl_socket = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET,
AttributeError: module 'socket' has no attribute 'AF_BLUETOOTH'

Y0ngg4n avatar Apr 24 '21 19:04 Y0ngg4n

On OpenSUSE, it seems that python is compiled without bluetooth support because the compilation introduces a circular dependency.

https://lists.opensuse.org/archives/list/[email protected]/message/J65TRIE7UA5G37DWEGRRW7GH2KISLY62/

The solution suggested in that thread is to use pybluez BluetoothSocket:

https://pybluez.readthedocs.io/en/latest/api/bluetooth_socket.html

furlongm avatar Apr 27 '21 03:04 furlongm