Discussion:
[pyusb-users] now we're cooking
Anony Mous
2014-11-03 23:44:21 UTC
Permalink
$ python
import ctypes
import ctypes.util
ctypes.util.find_library('libusb-1.0')
Does it work on your environment?
No. But it does give a hint!

=====================

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py",
line 423, in LoadLibrary
return self._dlltype(name)
File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py",
line 345, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libusb-1.0.dylib, 6): no suitable image found. *Did find:*
* /usr/local/lib/libusb-1.0.dylib: mach-o, but wrong architecture*
==========================

Thus:

==> file libusb-1.0.0.dylib

libusb-1.0.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64

so.... I need 32 bit. ok then:

==> sudo rm -f /usr/local/lib/libusb*
==> sudo make clean
==> sudo ./configure CXXFLAGS="-m32 -arch 386" CFLAGS="-m32"
==> sudo make
==> sudo make install
import ctypes
import ctypes.util as x
x.find_library('libusb-1.0')
'/usr/local/lib/libusb-1.0.dylib'
...which looks good, so I messed with some more testcode, and as long as I
do this first...

mybackend = usb.backend.libusb1.get_backend(find_library=lambda x:
"/usr/local/lib/libusb-1.0.dylib')

...then usb.lib and usb.core act reasonably.

Still not sure why it's not finding the library itself, though.

Thanks for the help, everyone. Kudos to the bunch of yas. :)

Loading...