2
votes

I am running OS X 10.5 and am trying to connect to a USB device via PyUSB with the following code.

   import usb.core, time, usb

   dev = usb.core.find(idVendor=0x054c,idProduct=0x0155)
    if dev is None:
      raise ValueError('Device not found')           # if device not found report an error

Though the value error 'device not found' is thrown. OS X System Profiler denotes the devices product and vendor id as..

      EyeToy USB camera Namtai:

      Product ID: 0x0155
      Vendor ID: 0x054c  (Sony Corporation)
      Version: 1.00
      Speed: Up to 12 Mb/sec
      Manufacturer: Sony corporation
      Location ID: 0x06200000 / 3
      Current Available (mA): 500
      Current Required (mA): 500

Solution: Had to manual install libusb-1.0.8. Mac-ports didn't install libusb correctly.

3
I'm having a similar issue, usb.core.find() only works when running the python interpreter (or script) with sudo. What worries me is that, if not ran with sudo, the library is not found, which doesn't happen in last Snow Leopard, any tips?Nico
Interfacing with hardware requires 'sudo' privileges.Robert Northard

3 Answers

1
votes

Homebrew install of libusb helped for me

[sudo] brew install libusb
3
votes

Try enumerating your devices via PyUSB. This example is from the docs to find all printers (device class 7):

printers = usb.core.find(find_all=True, bDeviceClass=7)

This should hopefully include your device and you can see what the fields actually are. Your camera is probably class 0x0e or 0x10.

0
votes

I had the same issue and had installed libusb via MacPorts but was using python installed via pyenv.

Make sure you use the python version installed via MacPorts.

which python

The above code should tell you the location of python version you are using. It should say /opt/local/bin/python2.7 or whichever version you have installed via MacPorts.

I think the issue is because python installed via pyenv or pre-installed python (shipped with macOS) looks for the libusb library under /usr whereas MacPorts installs the library under /opt/local.