我的系统上安装了 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
它使用 Python 2,正如预期的那样。
但是,当我运行此命令时,出现以下错误:
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(我认为是正确的)。
为什么会发生此错误?