我的系统上安装了Python 2和Python 3。
我运行以下脚本:
#!/usr/bin/env python
import nxt.locator
from nxt.motor import *
def spin_around(b):
m_left = Motor(b, PORT_B)
m_left.turn(100, 360)
m_right = Motor(b, PORT_C)
m_right.turn(-100, 360)
b = nxt.locator.find_one_brick()
spin_around(b)使用命令:python spin.py,它按照预期使用Python2。
然而,当我运行这个命令时,我会得到以下错误:
Traceback (most recent call last):
File "spin.py", line 12, in <module>
b = nxt.locator.find_one_brick()
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 112, in find_one_brick
for s in find_bricks(host, name, silent, method):
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 43, in find_bricks
for s in socks:
File "/Library/Python/2.7/site-packages/nxt/usbsock.py", line 84, in find_bricks
for bus in usb.busses():
File "/Library/Python/2.7/site-packages/usb/legacy.py", line 353, in busses
sorted(core.find(find_all=True), key=lambda d: d.bus),
File "/Library/Python/2.7/site-packages/usb/core.py", line 1263, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available当我运行这个脚本时,我的NXT是通过USB插入到我的计算机上的,我的NXT是打开的。此外,我已经安装了pyUSB (我认为是正确的)。
为什么会发生这样的错误?
发布于 2016-12-24 15:12:42
解决方案是安装libUSB。pyUSB库在后台似乎依赖于libUSB。
我在libUSB中安装了brew install libusb
之后,这个特定的错误被修复了。
https://stackoverflow.com/questions/41310102
复制相似问题