How to use Hamilton STAR with Mac?

I try to run my Hamilton STAR with my Mac M1 Monterey 12.5. I saw here that it should be possible. I installed from source with all additional dependencies. If I connect my Mac via USB to Hamilton and try to open a communication I expect to not getting an error but I get:

Traceback (most recent call last):
  File "/Users/maxhager/Projects2022/KiwiBiolab/PyLabRobot/test.py", line 9, in <module>
    lh.setup()
  File "/Users/maxhager/Projects2022/KiwiBiolab/PyLabRobot/pylabrobot/pylabrobot/liquid_handling/liquid_handler.py", line 104, in setup
    self.backend.setup()
  File "/Users/maxhager/Projects2022/KiwiBiolab/PyLabRobot/pylabrobot/pylabrobot/liquid_handling/backends/hamilton/STAR.py", line 404, in setup
    self.dev = usb.core.find(idVendor=0x08af)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/usb/core.py", line 1309, in find
    raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available

Why I am getting this error?

Hi,

You are missing a backend for PyUSB. See here. For convenience, on a Mac you can simply run brew install libusb if you’re using Homebrew.

If you are still having errors after installing a backend, try this.

Hope that helps!

Thanks for the fast reply. Will test that as soon I am back in the lab.

I saw that you used conda environment in your video. If someone is not using conda environment brew install libusb is not enough.

After brew install libusb it’s necessary to go into folder /opt/homebrew/Cellar/libusb/1.0.26/lib/ copy all the content and paste it into /usr/local/lib.

1 Like

Actually, I was not using a conda environment.

It seems that you may not have Homebrew in your path. Does running

echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile

help?

I tried it but this didn’t worked. This works for me.

I’m glad that your solution worked. Since this is not something users should be expected to do, I am interested in identifying the root cause of the issue and I’m still not sure why brew install libusb did not work for you. Most likely, this is a libusb issue and not a PyLabRobot issue. I plan on looking into this more so that other users don’t encounter this.

Did you get any errors during the installation? What error did you get after installing and trying to use pyusb?

I wonder if any other Mac users have any ideas.

If you want to dig deeper into it perhaps have a look here.

Definitely agree with rick that it seems like a PATH issue. Can you show us your PATH please? echo $PATH (or similar, depending on shell)

2 Likes

After running echo $PATH from shell I got

/opt/homebrew/bin:/Users/maxhager/opt/anaconda3/bin:/Users/maxhager/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/opt/homebrew/opt/fzf/bin

looks weird.

Are you using your System’s Python installation by any chance?

System Python should not have access to brew because it’s not in the path, right? Let us perhaps look again on the issue if another user should be confronted with it.

System Python is definitely in your path, but it may not have access to libraries imported with Homebrew. That would be my best guess given the current information.

FYI, it is generally not recommended to use system Python. See here and here, for example.

2 Likes

Oh wow. I just deleted my files from /usr/local/lib and it’s working. Idk which issues I had. I can confirm that a brew install libusb is enough.

Great!

Did you run brew install python at any point? (Can you share the output of ls -l $(where python))

Not during the time of the issue.

/Users/maxhager/opt/anaconda3/bin/python → python3.9

But this is not the Python with which I run PyLabRobot. I run PyLabRobot with Python from /usr/local/bin/python3.

Did you run it afterwards, before things started working?

Is it a symlink? (ls -l /usr/local/bin/python)

No.

Yes. lrwxr-xr-x 1 root wheel 70 Aug 15 09:43 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3

It looks like you installed from python.org, perfect! Glad this fixed it.

Yes!