New install usb problems

I’m back again. I feel like I’m spamming the board here with dumb problems but here goes…see here for where this began: USB device not found error (potential macOS 15 issue?) - #10 by jonlaurent

In light of the above thread I’m now getting up and running with PLR on a brand new computer with macOS 14.7.

I installed PLR inside a virtual environment set up with pyenv with python 3.12.6. I following the standard instructions, cloning and nstalling from source, and then installing pyusb/libusb but have had a hell of a time getting PLR working after that.

At first I was getting No backend available errors, and troubleshooting suggested the libusb package was not visible to pyusb or PLR for some reason. After banging my head a few more times I found this post: Python on M1 MBP trying to connect to USB devices - NoBackendError: No backend available - Stack Overflow and tried the symlink fix, which bypassed the no backend error, but now I have something else still related to libusb:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~/.pyenv/versions/3.12.6/envs/automation-env/lib/python3.12/site-packages/usb/backend/libusb1.py:961, in get_backend(find_library)
    960 if _lib_object is None:
--> 961     _lib = _load_library(find_library=find_library)
    962     _setup_prototypes(_lib)

File ~/.pyenv/versions/3.12.6/envs/automation-env/lib/python3.12/site-packages/usb/backend/libusb1.py:287, in _load_library(find_library)
    285     win_cls = None
--> 287 return usb.libloader.load_locate_library(
    288             ('usb-1.0', 'libusb-1.0', 'usb'),
    289             'cygusb-1.0.dll', 'Libusb 1',
    290             win_cls=win_cls,
    291             find_library=find_library, check_symbols=('libusb_init',))

AttributeError: module 'usb' has no attribute 'libloader'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
Cell In[8], line 2
      1 ## Connect to robot
----> 2 await lh.setup()

File ~/FutureHouse/Lab/Automation/pylabrobot/pylabrobot/liquid_handling/liquid_handler.py:144, in LiquidHandler.setup(self, **backend_kwargs)
...
    966     # exception already logged (if any)
    967     _logger.error('Error loading libusb 1.0 backend', exc_info=False)
    968     return None

AttributeError: module 'usb' has no attribute 'libloader'

I had no problems getting PLR working with a new install in the past so I feel like I’ve majorly borked something here. Since this is a brand new computer I’m not above starting fresh once again if it will fix things :upside_down_face:

2 Likes

Ok I guess scratch this? I just came back to it and restarted vscode and it’s working now. I had already tried that once without success, so who knows…

1 Like

glad it seems to be fixed!

i remember i had to install python and libusb both using homebrew for it to work

please keep it going, having an online reference of these issues is super helpful

2 Likes

I think there may be something to this. Previously I had installed python via brew in my virtualenv, this time it was tied in with installing pyenv-virtualenv according to this: The right way to install Python on a Mac | by Raphaël Hoogvliets | Marvelous MLOps | Medium

if it works it works :man_shrugging:

in case it’s useful to anyone my setup is

  • macos 14.6, update procrastination was rewarded thanks to @jonlaurent’s warning
  • install python using homebrew @3.9
  • use python -m venv env to create an env
  • install plr in edit mode using pip install -e

and

  • raspberry pi running debian 12
  • python 3.11 with apt get
  • also -m venv env and install -e
1 Like