Parthiban Santhanam
Parthiban Santhanam

Reputation: 33

How does one get Python to find `libusb`? `pyusb` needs it for a backend

I am trying to use Python 2.7 with PyUSB to talk to a National Instruments DAQ board. I am using a MacBook Pro and running Yosemite 10.10.4. I have been able to install Python and the PyUSB package without any obvious problems, but when I try to use PyUSB, it cannot find a backend library:

>>> import usb.core
>>> usb.core.find()

Traceback (most recent call last):
  File "<pyshell#83>", line 1, in <module>
    usb.core.find()
  File        "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/usb/core.py", line 1199, in find
    raise ValueError('No backend available')
ValueError: No backend available

I have attempted to install libusb-1.0 multiple different ways but Python cannot seem to find any module named libusb. I tried:

  1. Downloading the tarball from SourceForge

  2. Installing brew and using "brew install libusb-compat" and "brew link libusb-compat"

  3. using sys.path.append("/usr/local/lib") to help Python find libusb

and this is where I get desperate:

  1. Using pip to "pip install libusb" (does pip even work with libraries?)

  2. Copying the contents of /usr/local/lib where the libusb-1.0.dylib and other libusb files are located to various locations where I thought Python might be looking for it.

Nevertheless, when I call help("Modules") in either IDLE or iPython, nothing resembling libusb shows up and calls to usb.core.find() continue to complain about a missing Backend.

How does one get Python to find libusb? Is the fact that it doesn't show up in help("Modules") even related to usb.core.find() complaining about a lack of a Backend?

I've dropped a good day on this so far and read a good 20 Q&As with no avail. Any advice would be quite welcome at this point. Also, this is my first ever question for stackoverflow, so please ask me to clarify if I've omitted critically enabling information or structured my question poorly. Thanks.

Upvotes: 3

Views: 6776

Answers (1)

David Grayson
David Grayson

Reputation: 87376

Did you try brew install libusb? The libusb-compat library is just a library that allows applications written for libusb 0.1 to work with libusb 1.0. I would think that PyUSB would already work with libusb 1.0 these days, so it wouldn't need some compatibility layer like that. You might also need to use a version of python installed from brew instead of using whatever version you are using now; I'm not sure.

Upvotes: 1

Related Questions