0

I have this (http://www.gesytec.de/en/download/easylon/p/16/) USB device connected to my Win7. I am just trying to read the vendor ID and product ID. I have Python 2.7.

Here is the code,

import usb
busses = usb.busses()
for bus in busses:
    devices = bus.devices
    for dev in devices:
        print "Device:", dev.filename
        print "  idVendor: %d (0x%04x)" % (dev.idVendor, dev.idVendor)
        print "  idProduct: %d (0x%04x)" % (dev.idProduct, dev.idProduct)

I am getting following error,

"File "<stdin>", line 1, in <module>
File "C:\Python27\lib\usb\core.py", line 846, in find
raise ValueError('No backend available')
ValueError: No backend available"

enter image description here What am I doing wrong here?

enter image description here

usustarr
  • 418
  • 1
  • 5
  • 21
  • I see similar issues [here](http://stackoverflow.com/questions/13773132/pyusb-on-windows-no-backend-available) and [here](http://stackoverflow.com/questions/25756032/pyusb-valueerror-no-backend-available). – David Mar 20 '15 at 19:54

3 Answers3

1

Did you install the usb library package? If so you may need to add it to your path.

Anonymous
  • 46
  • 1
0

I ended up using the dll provided by manufacture instead of USB lib.

usustarr
  • 418
  • 1
  • 5
  • 21
0

currently used library

import usb.core
import usb.backend.libusb0
backend = usb.backend.libusb0.get_backend(find_library=lambda x: "C:\Windows\system32\libusb0.dll")

# find your device #1
devices = usb.core.find(find_all=True)
for d in devices:
    print(d)

# find your device #2
import usb
busses = usb.busses()
for bus in busses:
    devices = bus.devices
    for dev in devices:
        print("Device:", dev.filename)
        print ("  idVendor: %d (0x%04x)" % (dev.idVendor, dev.idVendor))
        print ("  idProduct: %d (0x%04x)" % (dev.idProduct, dev.idProduct))
E. Zeytinci
  • 2,642
  • 1
  • 20
  • 37
  • While this code may provide a solution to OP's problem, it is highly recommended that you provide additional context regarding why and/or how this code answers the question. Code only answers typically become useless in the long-run because future viewers experiencing similar problems cannot understand the reasoning behind the solution. – E. Zeytinci Jan 12 '20 at 11:33