After running a python code for usb device following error is occured

Traceback (most recent call last):
File "test1.py", line 6, in
dev = usb.core.find(idVendor=0x1d6b, idProduct=0x0001)
File "/usr/lib/python2.7/site-packages/usb/core.py", line 1263, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available

Dani AI

Generated

usb.core.NoBackendError means PyUSB could not load a libusb runtime on the target system. In Buildroot-based images this often happens even when you selected libusb at build time, because the shared library is missing on the target, its SONAME/symlink is not present, or ctypes.util.find_library() cannot locate it (busybox systems typically lack ldconfig/ld cache).

Quick checks on the target:

  • Verify the library exists:

    ls -l /usr/lib/libusb-1.0.so*
    python -c "import ctypes.util; print(ctypes.util.find_library('usb-1.0'))"
  • If it exists but is not found, add it to the loader path or create a SONAME symlink:

    export LD_LIBRARY_PATH=/usr/lib
    ln -s /usr/lib/libusb-1.0.so.0 /usr/lib/libusb-1.0.so

In Buildroot, ensure you enabled BR2_PACKAGE_LIBUSB (or LIBUSB_COMPAT for 0.1) and that the shared library is included in the rootfs, not only static libs. On minimal systems you can explicitly point PyUSB to the library:

import usb.core
import usb.backend.libusb1 as libusb1

backend = libusb1.get_backend(find_library=lambda name: "/usr/lib/libusb-1.0.so.0")
dev = usb.core.find(idVendor=0xXXXX, idProduct=0xYYYY, backend=backend)

Note: 0x1d6b:0001 is the Linux Foundation root hub; it is not a normal user-space device to talk to. Test with a simple peripheral and expect to need udev rules or root privileges afterward.

Useful refs: PyUSB getting started and backends (https://pyusb.github.io/pyusb/), libusb project page (https://libusb.info), and Python’s find_library behavior (https://docs.python.org/3/library/ctypes.html#ctypes.util.find_library). Set PYUSB_DEBUG=debug for more diagnostics.

Recommended Answers

All 4 Replies

You might try the fix suggested here.

commented: I am using Linux machine.Libusb is properly installed +1

please help.I am compiling buildroot ( is properly installed.

sorry for the link
the correct link is

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.