Closed Jaharmi closed 4 years ago
The error in your traceback comes from ctypes.util.find_library
failing to find the installed hidapi
library.
import ctypes.util
print(ctypes.util.find_library('hidapi'))
I'm not familiar with port
so I don't know how it manages the files it installs.
Since reporting the issue, I was able to get this to work:
hidapi
directly on macOS Catalina, which I couldn't get to work.hidapi
on macOS Mojave, which installed it to /usr/local/lib
.hidapi
and this module on Mojave to control a Blynclight. Yay!hidapi
files to the same location on macOS Catalina.So, it seems like the problem is either with a) what the MacPorts port
command produced or b) with the location where it was installed. MacPorts installs under /opt
.
Assuming it compiled correctly, I'm wondering if the /opt
location is or can be searched for the library. I'm not sure how to check — or set — that for libraries (like PATH for executables).
From MacPorts:
$ ls -1 /opt/local/lib/ | grep hid
libhidapi.0.dylib
libhidapi.a
libhidapi.dylib
What I copied from macOS Mojave:
$ ls -1 /usr/local/lib/ | grep hid
libhidapi.0.dylib
libhidapi.a
libhidapi.dylib
libhidapi.la
Update: I found these references:
The MacPorts path of /opt
is not in the list, per the Stackoverflow article. I'm still not sure how to / if it's possible to add a path for ctypes.util.find_library
to search.
Update 2: Also found something that appears similar:
I will keep looking to find a way to add /opt
.
Thanks for all the detailed information on what you had to do to get BlyncLight running!
I'll dig into find_library
and see if I can improve how the shared library is located.
So looking at the code for ctypes.util.macholib.dylib
I found an environment variable you can set to help find_library
.. uh.. find the library.
$ export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
I tested this on my macOS 10.15.5 installation after installing Mac Ports:
$ which port
/opt/local/bin/port
$ brew uninstall hidapi
...
$ blync -a
<blows up>
$ sudo port install hidapi
...
$ blync -a
<still blows up, expected>
$ export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
$ blync -a
Number of available lights: 1
KEY:ID:VALUE
path:00:IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/TRP0@7/IOPP/PXSX@0/IOPP/pci-bridge@2/IOPP/pci1b21,1242@0/AppleUSBXHCIPCI@00000000/AppleUSB20XHCIPort@00300000/Blynclight Plus@00300000/IOUSBHostInterface@0/AppleUserUSBHostHIDDevice
vendor_id:00:0x2c0d
product_id:00:0x10
release_number:00:0x100
product_string:00:Blynclight Plus
usage_page:00:0xff00
usage:00:0x1
interface_number:00:0x0
Add that to your shell's profile script and you should be able to skip copying things to /usr/local.
I've gotten an
hidapi
error on macOS Catalina (v10.15.5, build 19F101). I saw there was an earlier issue and changes back and forth between usinghidapi
andlibusb
.My Python3 virtual environment was freshly created with Python 3.7.3 from the Python.org installer. I installed
libusb
(libusb @1.0.23) andhidapi
(hidapi @0.9.0_0) with MacPorts.Here is what I see with
system_profiler SPUSBDataType
. I have the Blynclight plugged into a port on an old Apple Cinema Display HD, which is plugged into the computer.I'm still messing around to see if I can figure things out, but I figured I'd file an issue in case it's known not to work with Catalina or something.