PyUsb does not recognize my USB device while my PC does

Viewed 3093

I'm trying to communicate between the my PC and PIC18F4550, but the program is not detecting it whereas the computer is showing it in Device Manager.

import usb.core

dev = usb.core.find(idVendor = 0x04D8, idProduct = 0xFEAA)

The function for checking USB devices:

def find(find_all = False, backend = None, custom_match = None, **args):
    def device_iter(k, v):
        for dev in backend.enumerate_devices():
            d = Device(dev, backend)
            if  _interop._reduce(lambda a, b: a and b,map(operator.eq,v,map(lambda i:getattr(d,i),k)),True)and (custom_match is None or custom_match(d)):
                yield d
        if backend is None:
            import usb.backend.libusb1 as libusb1
            import usb.backend.libusb0 as libusb0
            import usb.backend.openusb as openusb

            for m in (libusb1, openusb, libusb0):
                backend = m.get_backend()
                if backend is not None:
                    _logger.info('find(): using backend "%s"', m.__name__)
                       break
                 else:
                    raise ValueError('No backend available')

        k, v = args.keys(), args.values()

        if find_all:
            return device_iter(k, v)
        else:
            try:
                return _interop._next(device_iter(k, v))
            except StopIteration:
                return None

Error which I'm getting while running the code.

Traceback (most recent call last):
 File "C:\modules\motor.py", line 29, in <module>
   dev = usb.core.find(idVendor=0x04D8,idProduct=0xFEAA)
 File "C:\Python27\lib\site-packages\usb\core.py", line 1199, in find
   raise ValueError('No backend available')
 ValueError: No backend available

Before it used to execute properly, but for the past few days it's showing this error. I don't understand what happened all of sudden. Is there any problem using the PyUSB modules?

I have seen some of them getting the same problem while using USB communication.


I've sorted out the problem. The solution is that PyUSB module will search for libusb0.dll and libusb-1.0.dll files which are backends to communicate with USB devices which we need to include in PATH environment variable.

1 Answers
Related