skuep / AIOC

Ham Radio All-in-one-Cable
MIT License
736 stars 57 forks source link

Python script: No module named 'hid' #91

Open W1BTR opened 1 week ago

W1BTR commented 1 week ago

When attempting to run the python script on a fresh linux installation I get:

sudo python3 aioc.py
Traceback (most recent call last):
  File "aioc.py", line 2, in <module>
    import hid
ModuleNotFoundError: No module named 'hid'
W1BTR commented 1 week ago

In installed python3-pip and then ran sudo pip install hidapi

Now I get:

Traceback (most recent call last):
  File "aioc.py", line 70, in <module>
    aioc = hid.Device(vid=0x1209, pid=0x7388)
AttributeError: module 'hid' has no attribute 'Device'
skuep commented 1 week ago

I think you need to install "hid" and not "hidapi" (I know it's stupid how many trash is now on pypi). Can you remove the hidapi and install hid?

W1BTR commented 1 week ago

Ty for the fast reply.

Got it, now I get this error,

Traceback (most recent call last):
  File "aioc.py", line 2, in <module>
    import hid
  File "/usr/local/lib/python3.8/dist-packages/hid/__init__.py", line 125, in <module>
    hidapi.hid_get_input_report.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
  File "/usr/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /lib/x86_64-linux-gnu/libhidapi-hidraw.so.0: undefined symbol: hid_get_input_report

Perhaps it's related to the fact Im running this on WSL, although the port is passed through to the container so it shouldnt change anything. I have libhidapi-hidraw0 libhidapi-libusb0 installed, too. Not sure if those are the right ones. When I uninstall them it complains they are missing.

skuep commented 1 week ago

Looks to be a version issue with the libraries in WSL probably being quite old. https://medium.com/devopss-hole/python-error-undefined-symbol-hid-get-input-report-c01af1ccf1f6

pip uninstall hid
pip install hid==1.0.4
W1BTR commented 1 week ago

New error upon doing that:

lucas@MONEY-PIT:~$ sudo lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 1209:7388 Generic All-In-One-Cable
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lucas@MONEY-PIT:~$ sudo python3 aioc.py
Traceback (most recent call last):
  File "aioc.py", line 70, in <module>
    aioc = hid.Device(vid=0x1209, pid=0x7388)
  File "/usr/local/lib/python3.8/dist-packages/hid/__init__.py", line 130, in __init__
    raise HIDException('unable to open device')
hid.HIDException: unable to open device
lucas@MONEY-PIT:~$
skuep commented 1 week ago

Well, that's s verbose error message! 😅 No idea, unfortunately. I know of people using this under Windows (using Windows hid driver backend) and I am using it under native Linux with hidapi backend. Not sure if WSL trips over the libusb stuff or something