1FAQ 2=== 3 4How do I fix "No backend available" errors? 5------------------------------------------- 6 7Generally, there are four possible causes for this problem: 8 91. You didn't install libusb library. 102. Your libusb library isn't in the standard shared library paths. 113. Your libusb version is too old. 124. Your PyUSB version is too old. 13 14To debug what's wrong, run the following script in your environment:: 15 16 import os 17 os.environ['PYUSB_DEBUG'] = 'debug' 18 import usb.core 19 usb.core.find() 20 21This will print debug messages to the console. If you still have problems 22to figure out what's going on, please ask for help in the mailing list, 23providing the debug output. 24 25How do I install libusb on Windows? 26----------------------------------- 27 28To install either libusb_ or libusb-win32_ on Windows, please use zadig_. 29 30.. _zadig: http://zadig.akeo.ie/ 31.. _libusb: https://libusb.info 32.. _libusb-win32: http://www.libusb.org/wiki/libusb-win32 33 34How do I enforce a backend? 35--------------------------- 36 37Here is an example for the *libusb1* backend:: 38 39 >>> import usb.core 40 >>> from usb.backend import libusb1 41 >>> be = libusb1.get_backend() 42 >>> dev = usb.core.find(backend=be) 43 44How can I pass the libusb library path to the backend? 45------------------------------------------------------ 46 47Check the *Specify libraries by hand* section in the tutorial_. 48 49.. _tutorial: https://github.com/walac/pyusb/blob/master/docs/tutorial.rst 50 51How (not) to call set_configuration() on a device already configured with the selected configuration? 52----------------------------------------------------------------------------------------------------- 53 54Typically ``set_configuration()`` is called during device initialization. The `libusb documentation`_ on ``libusb_set_configuration()`` states: 55 56.. _libusb documentation: http://libusb.org/static/api-1.0/group__dev.html#ga186593ecae576dad6cd9679f45a2aa43 57 58 If you call this function on a device already configured with the selected configuration, then this function will act as a lightweight device reset: it will issue a SET_CONFIGURATION request using the current configuration, causing most USB-related device state to be reset (altsetting reset to zero, endpoint halts cleared, toggles reset). 59 60Calling ``write()`` subsequently will therefore result in a timeout error. 61 62One solution to this behaviour is to consider the currently active configuration, as described in the `configuration selection and handling`_. "If the configuration we want is already active, then we don't have to select any configuration":: 63 64 cfg = dev.get_active_configuration() 65 if cfg is None or cfg.bConfigurationValue != cfg_desired: 66 dev.set_configuration(cfg_desired) 67 68.. _configuration selection and handling: http://libusb.org/static/api-1.0/caveats.html 69 70