Missing dependency (pyusb) Laptop (that this was 100% working on) decided to die

RESOLVED
…missing dependency (pyusb)

Laptop (that this was 100% working on) decided to die on me (hard drive starting to go bad), so I had to set up on another laptop while I wait for a replacement hard drive in the mail. Got everything setup per the usual instructions, but running into an issue that gives the error “global name ‘usb’ is not defined”. running from command line, I get “Unable to load USB library (Sending data to Laser will not work.)” right before the gui shows up for k40 whisperer. Google searches have turned up nothing so far. Any suggestions on what I need to fix here?

Running in a Linux environment.

Did you install pyusb?
“sudo pip install pyusb”

1 Like

That was the missing component. Adding a dependency list to the Linux ReadMe would definitely be in order.

I can help you with that sometime if you’d like. Basically set up a clean install on a spare laptop I have lying around and figure out all the package dependencies you need to get everything up and running (with the lowest level install, so all necessary deps are covered, not just ones that are already in popular distros) so anyone setting this up can skip having to ask any dependency questions in the future.

This would also be extremely beneficial if I wish to make an installer script for my flavor of Linux in the future.

@CPUnltd I am glad you got it working. Step #10 in the Readme_Linux.txt file should have installed pyusb for you. (There is a line for pyusb in the requirements.txt file)

Ah, didn’t initially notice the requirements.txt file

Scorch is on fire!!! I have gerbil controller but I’ve not finished hooking it up because I’d miss K40 Whisperer which currently only communicates to the stock nano controller.

I see what you did there… :stuck_out_tongue:

I should note here the reason I didn’t think to follow that step in the instructions is because I’m using Archlinux (or Manjaro, which is a spin off of Arch), and installing anything I usually go through the package manager. Which all the files in requirements.txt are in the repository, so we’re all good. :slight_smile:

I think tk is a required package as well. I got a tkinter error today when I set it up on yet another laptop.

I’m unable to get this to work. I’ve installed all the required dependencies yet I still get this error. I’m using a fresh install of Manjaro Linux

if you are getting the "Unable to load USB library (Sending data to Laser will not work.)” error it is most likely that the library is not properly installed.

You can also get other USB errors if your user account does not have permission to access the USB port. To check this you can try running K40 Whisperer with root privileges.
(i.e. by typing: sudo python k40_whisperer.py)

1 Like

Best thing I’ve found is running it as root with sudo. I don’t get any errors of any kind anymore, and I think that was my ending solution to the situation. I am also running Manjaro, so I have roughly the same setup as the OP. See what happens if you run it from the commandline via sudo. If it works, you can make a script that you can drop in your /usr/bin folder to make executable that goes into the folder (I’d recommend keeping the k40 folder in /opt somewhere), then runs the .py file. This is what I did, then I run everything from synapse (basically the equivalent to the menu button with the search feature in gnome/kde/etc, but for any DE), type in my password and go without any issues.

That would be a USB device permissions problem, then. Better to fix that and not run as root…

I don’t know about Manjaro, but on Fedora there is a group called dialout (because historically it was used for modems, remember those?) that you can add yourself to and get permission for accessing USB devices. It looks like Arch Linux and thus Manjaro also use the dialout group, as well as Ubuntu and its derivatives, from a quick web search…

sudo usermod -a -G dialout $USER

Then log out and log back in again, and run the id command. You should see (dialout) in the output of the id command.

Yes, it is possible/better to give users access to the USB. I do remember that it was a pain to setup on my machine. I don’t recall how I got it working but it was no as simple as adding the user to the dialout group. I remember there were a lot of posts out there that lead me down the wrong path. I can only assume that the process is Linux distribution dependent.

Probably udev rules that cause the device to be assigned to the dialout group when it is discovered.

Sounds about right.