From: Steve K. <skr...@ve...> - 2021-01-20 23:24:42
|
On 1/20/2021 4:41 PM, Jonas Malaco wrote: > On Wed, Jan 20, 2021 at 6:20 PM Steve Kranish via pyusb-users > <pyu...@li...> wrote: >> This is a widely reported problem which has just been left dangling for >> many people. I have yet to see a complete, meaningful resolution. > This is not true. > > The solution, as you have already gathered, is to install libusb. As mentioned below, I have installed libusb 1.0.23b7 It installs 32 and 64 bit versions, or at least 32bit and 64 bit directories. The DLLs ARE different. I have copied the 64 bit library to c:\Windows\System32 AND my python working directory, where the py files are. > By the way, you haven't mentioned whether you're running 32 or 64 bit > Windows and Python. Windows 7 - 64 bit, Python 3.85, 64 bit > I have libusb-1.0.dll in c:\windows\system32 AND the directory where my >> python script exits. I still get the “No backend available” error. > Once common 64-bit Windows problem is that 64-bits DLLs go in > C:\Windows\System32 while 32-bit DLLs need to go in > C:\Windows\SysWOW64. > > Perhaps that's your issue? The 'library installation' directory is C:\Users\skranish\AppData\Local\Programs\Python\Python38\lib\site-packages\libusb I have used MS Process Monitor to see if libusb-1.0.dll is ever accessed. Python does look for it (QueryDirectory) in C:\Users\skranish\AppData\Local\Programs\Python\Python38\lib\site-packages\libusb and my working directory, but there is nothing in the log that indicates the file was ever accessed. It never looked in System32 or SysWOW64 Nonetheless, I put the 32 bit library in C:\Windows\SysWOW64. and the 64 bit library in C:\Windows\System32. I think I already had it that way. It does seem bass-ackwards to me. Perhaps this is of note? pyusb 1.1.0 should be the 64bit version pyUsb installs in C:\Users\skranish\AppData\Local\Programs\Python\Python38\lib\site-packages\pyusb-1.1.0.dist-info The files in this directory are: Directory of C:\Users\skranish\AppData\Local\Programs\Python\Python38\lib\site-packages\pyusb-1.1.0.dist-info 01/17/2021 04:53 PM <DIR> . 01/17/2021 04:53 PM <DIR> .. 01/17/2021 04:53 PM 4 INSTALLER 01/17/2021 04:53 PM 1,513 LICENSE 01/17/2021 04:53 PM 2,176 METADATA 01/17/2021 04:53 PM 2,340 RECORD 01/17/2021 04:53 PM 0 REQUESTED 01/17/2021 04:53 PM 4 top_level.txt 01/17/2021 04:53 PM 92 WHEEL 7 File(s) 6,129 bytes That is all! After copying the dll again (as above), and running again, I find that it DOES find a backend. According to Process Explorer, there is now an QueryNameInformationFile for: C:\Windows\System32\libusb-1.0.dll (because the program explicitly looks for it there!) in addition to accessing libusb-1.0.dll in the 'library install' directory. Perhaps I had the wrong version of the library somewhere? Thanks Steve import usb.core import usb.util from infi.devicemanager import DeviceManager dm = DeviceManager() devices = dm.all_devices for i in devices: try: print ('{} : address: {}, bus: {}, location: {}'.format(i.friendly_name, i.address, i.bus_number, i.location)) except Exception: pass import usb.backend.libusb1 backend = usb.backend.libusb1.get_backend(find_library=lambda x: "C:\\Windows\\System32\\libusb-1.0.dll") print(backend) dev = usb.core.find(backend=backend, find_all=True) print(dev) def EnumerateUSB(): #I use a simple function that scans all known USB connections and saves their info in the file with open("EnumerateUSBLog.txt", "w") as wf: counter = 0 for d in dev: try: wf.write("USB Device number " + str(counter) + ":" + "\n") print("USB Device number " + str(counter) + ":" + "\n") wf.write(d._get_full_descriptor_str() + "\n") print(d._get_full_descriptor_str() + "\n") # wf.write(d.get_active_configuration() + "\n") wf.write("\n") counter += 1 except NotImplementedError: wf.write("Device number " + str(counter) + "is busy." + "\n") wf.write("\n") counter += 1 except usb.core.USBError: wf.write("Device number " + str(counter) + " is either disconnected or not found." + "\n") wf.write("\n") counter += 1 wf.close() EnumerateUSB() |