Search code examples
libusb

How to install libusb manually on macOS (without Homebrew)


I tried to download libusb-1.0.0.dylib and move it to /usr/local/lib/libusb-1.0.0.dylib but Python still raised usb.core.NoBackendError. So after copying libusb to /usr/local/lib/libusb-1.0.0.dylib, should I do something else? I know many of you will suggest installing it with Homebrew but I don't like Homebrew now. Thanks in advance


Solution

  • pain... :)

    • download libusb-1.0.26.tar.bz2 from https://formulae.brew.sh/api/formula/libusb.json aka "https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2"
    • build with xCode to create the dynlib then archive / export the package. There is an Xcode project inside the package... or compile in your own way make/build...
    • copy the dynlib file to /opt/local/lib/libusb-1.0.dylib per hardcode in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/usb1/_libusb1.py ll 170 or choose 172 or 174... in method __getLibrary or symlink...
    • Xcode will spit out wrong file name so ensure you rename the file accordingly when you copy it. hope this helps.