ahtn / python-easyhid

A simple interface to the HIDAPI library.
MIT License
16 stars 8 forks source link

Can't use easyhid anymore on Mac #4

Open N0ury opened 4 years ago

N0ury commented 4 years ago

After an upgrade easyhid stopped working. I have tried to open a bug at hidapi site, but they say it's an easyhid issue.

Here's the problem:

Python 3.8.5 (default, Jul 21 2020, 10:48:26) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from easyhid import Enumeration
>>> en=Enumeration()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/easyhid/easyhid.py", line 366, in __init__
    self.device_list = _hid_enumerate(vid, pid)
  File "/usr/local/lib/python3.8/site-packages/easyhid/easyhid.py", line 428, in _hid_enumerate
    start = hidapi.hid_enumerate(vendor_id, product_id)
  File "/usr/local/lib/python3.8/site-packages/cffi/api.py", line 912, in __getattr__
    make_accessor(name)
  File "/usr/local/lib/python3.8/site-packages/cffi/api.py", line 908, in make_accessor
    accessors[name](name)
  File "/usr/local/lib/python3.8/site-packages/cffi/api.py", line 838, in accessor_function
    value = backendlib.load_function(BType, name)
AttributeError: function/symbol 'hid_enumerate' not found in library '<None>': dlsym(RTLD_DEFAULT, hid_enumerate): symbol not found
>>> 

But if I type the following code, it works:

Python 3.8.5 (default, Jul 21 2020, 10:48:26) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cffi
>>> ffi = cffi.FFI()
>>> hidapi = ffi.dlopen('hidapi')
>>> 
>>> from easyhid import Enumeration
>>> en=Enumeration()
>>> 

I'm using version: 0.0.10

pip3 show easyhid
Name: easyhid
Version: 0.0.10
Summary: A simple interface to the HIDAPI library.
Home-page: http://github.com/ahtn/python-easyhid
Author: jem
Author-email: jem@seethis.link
License: MIT
Location: /usr/local/lib/python3.8/site-packages
Requires: cffi
Required-by: 

What can I do ?

N0ury commented 4 years ago

Hi,

I think I have found the problem. One way to solve the issue is to change line 56 in easyhid.py. Replace
elif "Darwin" in platform.platform(): with
elif platform.platform().startswith("macOS"):

OndrejPistora commented 6 months ago

Forked repo with mentioned fix is here: https://github.com/bglopez/python-easyhid.git But it didnt fix it for me. I had to create a symlink sudo ln -s /opt/homebrew/Cellar/hidapi/0.14.0/lib/libhidapi.dylib /usr/local/lib/libhidapi.dylib as you can see i installed hidapi by homebrew brew install hidapi