Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#62661 closed defect (fixed)

py39-pyusb: "No backend available" error at runtime

Reported by: programmingkidx Owned by: reneeotten (Renee Otten)
Priority: Normal Milestone:
Component: ports Version: 2.6.4
Keywords: Cc:
Port: py-pyusb

Description

I installed pyusb like this: sudo port install py-pyusb. py39-pyusb was installed. I then opened python 3.9 from here: /opt/local/bin/python3.9. When I imported the usb.core module there were no problems. But when I tried to run this program I saw the error about no backend available:

import usb.core

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

Here is the full error:

Traceback (most recent call last):

File "<stdin>", line 1, in <module> File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/usb/core.py", line 1297, in find

raise NoBackendError('No backend available')

usb.core.NoBackendError: No backend available

I tried to fix the problem by installing libusb like this: sudo port install libusb. This did not fix the problem.

My info: Mac OS 11.1 M1 Mac Python 3.9

Change History (8)

comment:1 Changed 3 years ago by jmroot (Joshua Root)

Keywords: USB removed
Port: py-pyusb added; py39-pyusb removed
Summary: No backend available error when using py-pyusbpy39-pyusb: "No backend available" error at runtime

comment:2 Changed 3 years ago by reneeotten (Renee Otten)

Owner: set to reneeotten
Resolution: fixed
Status: newclosed

In a0b9898aed5dc8e0f17842110111d6bb272298bc/macports-ports (master):

py-pyusb: update to 1.1.1, move to PyPI

Closes: #62661

comment:3 Changed 3 years ago by reneeotten (Renee Otten)

I just updated the port to its latest version and when doing

import usb.core

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

I do not get the Traceback that you're seeing; please try update the port and try again, it might have been fixed in the newer version.

comment:4 Changed 3 years ago by programmingkidx

I ran 'port selfupdate' Then I ran 'port info py-pyusb'. It still shows this info: py-pyusb @1.1.0 (python, devel). I see the same info for py39-pyusb.

How do I update to version 1.1.1?

comment:5 Changed 3 years ago by reneeotten (Renee Otten)

that cannot be true... I did commit that change so you should be seeing the new version. Perhaps you were too quick to do the selfupdate, please try again now as it must have propagated now to the different places.

comment:6 Changed 3 years ago by programmingkidx

Ok, after running 'sudo port selfupdate', I was able to see version 1.1.1. After importing the usb module like this: import usb.core I ran 'help(usb._version)'. It showed this:

Help on module usb._version in usb:

NAME
    usb._version

DESCRIPTION
    # coding: utf-8
    # file generated by setuptools_scm
    # don't change, don't track in version control

DATA
    version = '1.1.1'
    version_tuple = (1, 1, 1)

FILE
    /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/usb/_version.py

I am sure I am using the right version.

I then ran this code: dev = usb.core.find(idVendor=0x0d8c,idProduct=0x0008)

I saw this error again:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/usb/core.py", line 1299, in find
    raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available

The USB device I am using is plugged in and detected by Mac OS 11. I was able to verify this in the 'System Information' application.

Please let me know if you need anything. Thanks.

comment:7 Changed 3 years ago by reneeotten (Renee Otten)

I am not sure it works for me on macOS 10.15.7, so it's probably something macOS 11 specific I would think...

if you look at the code is referenced in your traceback it shows that is't trying to get a backend for the three available options. The Portfile uses libusb version 1.0.24 and indeed for me that works

>>> import usb.backend.libusb1 as libusb1
>>> libusb1.get_backend()
<usb.backend.libusb1._LibUSB object at 0x10b61b4c0>

it that doesn't give anything for you, that's the problem. How to solve that I don't know... it might be that libusb is not working correctly on macOS 11. That's something you would have to figure out and/or report upstream; I don't think it's a MacPorts problem, at least not in the py-pyusb port.

comment:8 Changed 3 years ago by programmingkidx

libusb1.get_backend() returns None for me 😞

Note: See TracTickets for help on using tickets.