سؤال

I'm running Mac OS X 10.8 with python 2.7. I installed libusb with MacPorts and it does work (tested my importing usb.core & usb.util). However, each time I try to access a device, I get the following error:

>>> dev=usb.core.find(idVendor=0x1d50, idProduct=0x6048)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/usb/core.py", line 829, in find
raise ValueError('No backend available')
ValueError: No backend available

I've tried several other things, like import usb.backend, yet I wasn't sure what that was supposed to do. Same result, after 3 days of working on it.

Thanks for any help in advance!

EDIT: This has actually changed. I'm not sure which file I modified and how, but now the following works:

>>> import usb
>>> usb.core.find(idVendor=0x1d50, idProduct=0x6048)
<usb.core.Device object at 0x10eb2f2d0>

However, now when I run sudo rfcat -r (which is the real purpose of getting libusb working), I still get these error messages:

Error in resetup():ValueError('No backend available',)

EDIT: It seems that the issue is with ipython. When I start ipython as root and import usb, I'm not able to find my device:

In [1]: import usb

In [2]: import usb.util

In [3]: import usb.core

In [4]: usb.core.find(idVendor=0x1d50, idProduct=0x6048)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-7884198c46c2> in <module>()
----> 1 usb.core.find(idVendor=0x1d50, idProduct=0x6048)

/Library/Python/2.7/site-packages/usb/core.pyc in find(find_all, backend, custom_match, **args)
    827                 break
    828         else:
--> 829             raise ValueError('No backend available')
    830 
    831     k, v = args.keys(), args.values()

ValueError: No backend available

In [5]: 

EDIT: Jesis christ, once again. If I start python, then run the following:

>>> from IPython.frontend.terminal.ipapp import launch_new_instance
>>> launch_new_instance()

I get an ipython prompt. When in it I import usb and find my device, there isn't a backend error.

If I import usb in python, then do those commands above to get an ipython prompt, and then find my device, I get a "name 'usb' not defined" error. Then, I import usb and find my device, then there's no error.

At this point, I'm extremely confused. The commands above are exactly what /usr/local/bin/ipython contains, so I should be getting identical results.

هل كانت مفيدة؟

المحلول

I've gotten this fixed. Apparently, both rfcat and ipython binaries pointed to the wrong binaries of python - not /opt/local/bin/python. Changed that in vim, and it all runs fine.

Now, the issue is that libusb can't seem to get a good hold of the device - it can't do the most basic commands, but that's for another question.

نصائح أخرى

MacPorts installs libusb under /opt/local. Looks like you are using ipython installed under /usr/local which I guess is not installed via MacPorts.

/usr/local/bin/ipython probably looks for libusb library under /usr/local/include/ and not /opt/local/include/ where it is installed by MacPorts.

You can either install iPython via MacPorts since it will be able to look for libraries under /opt/local which are also installed using MacPorts or as @Slava answered you can modify rfcat and ipython to point to /opt/local/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top