blawar / nut

GNU General Public License v3.0
1.12k stars 193 forks source link

[Bug] M2 Mac: `usb exception: No backend available` #460

Open ericdude4 opened 1 year ago

ericdude4 commented 1 year ago

Describe the bug After following Mac install instructions (using asdf instead of pyenv) I am getting the following when running python3 nut_gui.py:

➜  nut git:(master) ✗ python3 nut_gui.py
loading blacklist /Users/foobar/Downloads/Switch/nut/conf/blacklist.online.txt
could not load find or load keys.txt, all crypto operations will fail. See keys_template.txt for an example of how this file should look
loaded user guest
                        ,;:;;,
                       ;;;;;
               .=\',    ;:;;:,
              /_\', "=. \';:;:;
              @=:__,  \,;:;:\'
                _(\.=  ;:;;\'
               `"_(  _/="`
                `"\'
loaded titledb/titles.json in 0.353336167 seconds
loaded file list in 0.0015640410000000715 seconds
initThread start
Sun Feb 12 12:36:48 2023 Server Starts - 0.0.0.0:9000
scanning /Users/foobar/Downloads/Switch
usb exception: No backend available
initThread finish
usb exception: No backend available
usb exception: No backend available
usb exception: No backend available
usb exception: No backend available
...

Regarding my libusb installation:

➜  nut git:(master) ✗ brew info libusb
==> libusb: stable 1.0.26 (bottled), HEAD
Library for USB device access
https://libusb.info/
/opt/homebrew/Cellar/libusb/1.0.26 (22 files, 595KB) *
  Poured from bottle on 2023-02-12 at 12:29:18
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libusb.rb
License: LGPL-2.1-or-later

To Reproduce Steps to reproduce the behaviour:

asdf install python 3.9.7
asdf local python 3.9.7
brew install pyqt@5
brew install libusb
cd /Users/foobar/.asdf/installs/python/3.9.7/lib/python3.9/site-packages && echo "/opt/homebrew/lib/python3.9/site-packages" >> homebrew.pth
pip install wheel
PYCURL_SSL_LIBRARY=openssl LDFLAGS="-L/opt/homebrew/opt/openssl/lib" CPPFLAGS="-I/opt/homebrew/opt/openssl/include" pip install pycurl
pip install -r requirements.txt
python3 nut_gui.py

Actual behaviour The application launches and behaves normally, but isn't able to recognize libusb.

Expected behaviour libusb is recognized as usb backend

Screenshots If applicable, add screenshots to help explain your problem.

NUT version (or git hash):

Additional context Running on M2 Max

Yamilquery commented 1 year ago

I had the same error on M1 Max:

loaded user guest
                        ,;:;;,
                       ;;;;;
               .=\',    ;:;;:,
              /_\', "=. \';:;:;
              @=:__,  \,;:;:\'
                _(\.=  ;:;;\'
               `"_(  _/="`
                `"\'
loaded titledb/titles.json in 0.399159458 seconds
loaded file list in 0.001259416999999985 seconds
initThread start
Fri Feb 24 16:01:57 2023 Server Starts - 0.0.0.0:9000
scanning .
usb exception: No backend available
initThread finish                                                                                                                           
usb exception: No backend available
usb exception: No backend available
usb exception: No backend available
usb exception: No backend available

You can solve it with:

ln -s /opt/homebrew/lib/libusb-1.0.0.dylib /usr/local/lib/libusb.dylib

Enjoy

renb0 commented 1 year ago

I had the same error on M1 Max:

loaded user guest
                        ,;:;;,
                       ;;;;;
               .=\',    ;:;;:,
              /_\', "=. \';:;:;
              @=:__,  \,;:;:\'
                _(\.=  ;:;;\'
               `"_(  _/="`
                `"\'
loaded titledb/titles.json in 0.399159458 seconds
loaded file list in 0.001259416999999985 seconds
initThread start
Fri Feb 24 16:01:57 2023 Server Starts - 0.0.0.0:9000
scanning .
usb exception: No backend available
initThread finish                                                                                                                           
usb exception: No backend available
usb exception: No backend available
usb exception: No backend available
usb exception: No backend available

You can solve it with:

ln -s /opt/homebrew/lib/libusb-1.0.0.dylib /usr/local/lib/libusb.dylib

Enjoy

Worked for me too, thanks!

matthewperiut commented 3 weeks ago

I'm not sure why but here's what I did to fix it:

sudo mkdir /usr/local/lib sudo ln -s /opt/homebrew/Cellar/libusb/1.0.27/lib/libusb-1.0.0.dylib /usr/local/lib/libusb.dylib

and that worked!