I have tried all possible ways but not able to get out this error.Did anyone sorted out this problem?

>>> import usb.core
>>> import usb.util
>>> dev=usb.core.find(idVendor=0x04D8)

Error I'm getting is:

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

Before it did not show any such issue it is displaying that error recently. Tried including libusb0_x86.dll in the directory C:\Python27 but still it is showing the error.Also i have installed the libusb-win32 inf wizard for the device driver. Please any python expert out here help me with this error.

2

There are 2 best solutions below

1
On

First of all change your third line. You must find your device with the idVendor and the IdProduct. So use this command:

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

Just replace the YYYY with the right informations.

Another possible issue is that a driver is already using your device when you run your code. Try to run your code in administrator.

0
On

Whenever we use PyUSB modules for USB communication with PC then PyUSB module will check for libusb0.dll and libusb-1.0.dll files (which act as backends) in the PATH environment variable and in C:\windows\System32 locations and then establishes communication with USB devices. Since i'm using libusb-win32-wizard for creating device drivers it uses libusb0.dll. The process of execution can be found using following DEBUG program:

import os
os.environ['PYUSB_DEBUG'] = 'debug'
import usb.core
print list(usb.core.find(find_all=True))

when i execute the above program in Shell, the output i got is:

2016-03-26 11:41:44,280 ERROR:usb.libloader:'Libusb 1' could not be found
2016-03-26 11:41:44,280 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend
2016-03-26 11:41:44,280 ERROR:usb.libloader:'OpenUSB library' could not be found
2016-03-26 11:41:44,280 ERROR:usb.backend.openusb:Error loading OpenUSB backend
2016-03-26 11:41:44,280 INFO:usb.core:find(): using backend "usb.backend.libusb0"
2016-03-26 11:41:44,280 DEBUG:usb.backend.libusb0:_LibUSB.enumerate_devices()
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200E530>)
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200E5D0>)
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200E6C0>)
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200E7B0>)
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200E8A0>)
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200E990>)
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200EA80>)
2016-03-26 11:41:44,296 DEBUG:usb.backend.libusb0:_LibUSB.get_device_descriptor(<usb.backend.libusb0._usb_device object at 0x0200EB70>)
[<DEVICE ID 046d:c05a on Bus 000 Address 001>, <DEVICE ID 046d:c31d on Bus 000 Address 002>, <DEVICE ID 046d:c31d on Bus 000 Address 003>, <DEVICE ID 046d:c31d on Bus 000 Address 004>, <DEVICE ID 04d8:feaa on Bus 000 Address 005>, <DEVICE ID 046d:082b on Bus 000 Address 006>, <DEVICE ID 046d:082b on Bus 000 Address 007>, <DEVICE ID 046d:082b on Bus 000 Address 008>]

So here since i gave the argument as find_all=True in usb.core.find() function it returns every device ID's connected to PC. Also in first 4 lines it gives error since we use lib-usb-win32-wizard which uses libusb0.dll and hence in 5th line it gave INFO:usb.core:find(): using backend "usb.backend.libusb0" which means it is using libusb0.dll for communicating with USB devices.