【问题标题】:nxt-python error: usb.core.NoBackendErrornxt-python 错误:usb.core.NoBackendError
【发布时间】:2016-12-24 03:35:32
【问题描述】:

我的系统上安装了 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(我认为是正确的)。

为什么会出现这个错误?

【问题讨论】:

    标签: python mindstorms nxt-python


    【解决方案1】:

    解决方案是安装 libUSB。 pyUSB 库似乎在后台依赖 libUSB。

    我用brew install libusb安装了libUSB

    之后,该特定错误得到修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-14
      • 1970-01-01
      • 2019-01-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多